You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(dockerfile): improve documentation and change working directory (#4)
- Installs code at /home/speckle to prevent collisions with files & directories in the root (/) directory
- Updates the README and provides instructions for building and testing the docker image locally
- Updated inline documentation in Dockerfile
Copy file name to clipboardExpand all lines: README.md
+49-22Lines changed: 49 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
# Speckle Automate function template - Python
2
2
3
-
4
3
This is a template repository for a Speckle Automate functions written in python
5
4
using the [specklepy](https://pypi.org/project/specklepy/) SDK to interact with Speckle data.
6
5
@@ -24,20 +23,9 @@ describe how the launch.json should be edited
24
23
25
24
### Github Codespaces
26
25
27
-
create new repo from template, and use the create new code
28
-
29
-
30
-
### Local dev environment
31
-
32
-
33
-
34
-
35
-
# Archive
26
+
Create a new repo from this template, and use the create new code.
36
27
37
-
This is a simple example of how to use the Speckle Automate Python package to automate the creation of a Speckle stream.
38
-
39
-
40
-
## Using this Speckle Function
28
+
### Using this Speckle Function
41
29
42
30
1.[Create](https://automate.speckle.dev/) a new Speckle Automation.
43
31
1. Select your Speckle Project and Speckle Model.
@@ -47,14 +35,10 @@ This is a simple example of how to use the Speckle Automate Python package to au
47
35
48
36
## Getting Started with creating your own Speckle Function
49
37
50
-
1.[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repository.
51
-
1.[Clone](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository) your forked repository to your development environment, or use [GitHub CodeSpaces](https://github.com/features/codespaces).
52
-
1.[Register](https://automate.speckle.dev/) your Function with [Speckle Automate](https://automate.speckle.dev/).
53
-
1. After completing the registration of the Function you will be shown a Function Publish Token and a Function ID. You will need these later.
54
-
1. Save your Function Publish Token as a [GitHub Action Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `SPECKLE_AUTOMATE_FUNCTION_PUBLISH_TOKEN`.
55
-
1. Save your Function ID as a [GitHub Action Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `SPECKLE_AUTOMATE_FUNCTION_ID`.
38
+
1.[Register](https://automate.speckle.dev/) your Function with [Speckle Automate](https://automate.speckle.dev/) and select the Python template.
39
+
1. A new repository will be created in your GitHub account.
56
40
1. Make changes to your Function in `main.py`. See below for the Developer Requirements, and instructions on how to test.
57
-
1.Every commit to `main` branch will create a new version of your Speckle Function.
41
+
1.To create a new version of your Function, create a new [GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) in your repository.
58
42
59
43
## Developer Requirements
60
44
@@ -66,7 +50,50 @@ This is a simple example of how to use the Speckle Automate Python package to au
66
50
## Building and Testing
67
51
68
52
The code can be tested locally by running `poetry run pytest`.
69
-
The code should also be packaged into the format required by Speckle Automate, a Docker Container Image, and that should also be tested.
53
+
54
+
### Building and running the Docker Container Image
55
+
56
+
Running and testing your code on your own machine is a great way to develop your Function; the following instructions are a bit more in-depth and only required if you are having issues with your Function in GitHub Actions or on Speckle Automate.
57
+
58
+
#### Building the Docker Container Image
59
+
60
+
Your code is packaged by the GitHub Action into the format required by Speckle Automate. This is done by building a Docker Image, which is then run by Speckle Automate. You can attempt to build the Docker Image yourself to test the building process locally.
61
+
62
+
To build the Docker Container Image, you will need to have [Docker](https://docs.docker.com/get-docker/) installed.
63
+
64
+
Once you have Docker running on your local machine:
65
+
66
+
1. Open a terminal
67
+
1. Navigate to the directory in which you cloned this repository
Once the image has been built by the GitHub Action, it is sent to Speckle Automate. When Speckle Automate runs your Function as part of an Automation, it will run the Docker Container Image. You can test that your Docker Container Image runs correctly by running it locally.
77
+
78
+
1. To then run the Docker Container Image, run the following command:
`docker run --rm speckle_automate_python_example` tells Docker to run the Docker Container Image that we built earlier. `speckle_automate_python_example` is the name of the Docker Container Image that we built earlier. The `--rm` flag tells docker to remove the container after it has finished running, this frees up space on your machine.
91
+
92
+
The line `python -u main.py run` is the command that is run inside the Docker Container Image. The rest of the command is the arguments that are passed to the command. The arguments are:
93
+
94
+
- `'{"projectId": "1234", "modelId": "1234", "branchName": "myBranch", "versionId": "1234", "speckleServerUrl": "https://speckle.xyz", "automationId": "1234", "automationRevisionId": "1234", "automationRunId": "1234", "functionId": "1234", "functionName": "my function", "functionLogo": "base64EncodedPng"}'` - the metadata that describes the automation and the function.
95
+
- `{}` - the input parameters for the function that the Automation creator is able to set. Here they are blank, but you can add your own parameters to test your function.
96
+
- `yourSpeckleServerAuthenticationToken` - the authentication token for the Speckle Server that the Automation can connect to. This is required to be able to interact with the Speckle Server, for example to get data from the Model.
0 commit comments