Refactor function input schema generation and execution
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled

- Update the command to generate the function input schema in `.github/workflows/main.yml`
- Add a new file `run.py` for executing the automate function
- Move the automate function execution code from `src/main.py` to `run.py`

These changes improve the organization and separation of concerns in the codebase.
This commit is contained in:
Jonathon Broughton
2024-08-04 15:36:48 +01:00
parent 03f6673cc0
commit 1e8dc4dfe5
3 changed files with 15 additions and 13 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ jobs:
- name: Extract functionInputSchema
id: extract_schema
run: |
python src/main.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
python run.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
- name: Speckle Automate Function - Build and Publish
uses: specklesystems/speckle-automate-github-composite-action@0.8.1
with:
@@ -35,6 +35,6 @@ jobs:
speckle_token: ${{ secrets.SPECKLE_FUNCTION_TOKEN }}
speckle_function_id: ${{ secrets.SPECKLE_FUNCTION_ID }}
speckle_function_input_schema_file_path: ${{ env.FUNCTION_SCHEMA_FILE_NAME }}
speckle_function_command: 'python -u src/main.py run'
speckle_function_command: 'python -u run.py run'
speckle_function_recommended_cpu_m: 4000
speckle_function_recommended_memory_mi: 4000
+13
View File
@@ -0,0 +1,13 @@
from speckle_automate import execute_automate_function
import sys
from pathlib import Path
# Add src to the sys.path
src_path = Path(__file__).resolve().parent / 'src'
sys.path.append(str(src_path))
from src.main import automate_function, FunctionInputs
if __name__ == "__main__":
# Entry point: Execute the automate function with defined inputs.
execute_automate_function(automate_function, FunctionInputs)
-11
View File
@@ -15,12 +15,6 @@ from objects.objects import (
from src.utilities.reporting import generate_pdf, write_pdf_to_temp, generate_summary
from src.utilities.utilities import filter_displayable_bases
## new render materials for objects passing/failing
## swap those into the original commit object
## send that back to the server
class FunctionInputs(AutomateBase):
"""Definition of user inputs for this function.
@@ -139,8 +133,3 @@ def automate_function(
automate_context.mark_run_success(
"Analysis complete. High-density objects within acceptable limits."
)
if __name__ == "__main__":
# Entry point: Execute the automate function with defined inputs.
execute_automate_function(automate_function, FunctionInputs)