Local development
During development you often need to quickly iterate and test your changes. If the step is pushed to the director at every iteration, this can add a lot of friction between writing the code and getting feedback by running the step. Local development mode can help reduce that friction.
Overview
Local development mode mounts a path on the local filesystem for an in-development step rather than building the step code into a published step. This allows the developer to push the step once, locally, then update code and run the step without having to push the changes first. This can speed up experimentation and iteration significantly. The downside to using this method is that it only works with a locally running director that is able to mount the provided path, so it is unsuitable for production deployments.
Comparing step types
Local | Docker | |
---|---|---|
Purpose | Fast local development | Production deployment |
Deployment | Local director only | Local or cloud director |
Updating | Push once, updated code automatically used | Push every time code is updated |
Running | Local director must be available | Step can run on any available director |
In order to use local development mode, it's necessary to have a director running locally on the developer's machine, preferably via Docker.
Pushing steps locally
Once you have a step that is ready to run for the first time, push it locally by using the sand steps push local
command:
$ sand steps push local --name localStep \
--volumeMountPath /path/to/step
Note the highlighted line: the --volumeMountPath
flag should point to the directory containing your code (if it is not in main.py
, use the --entrypoint
flag to indicate the correct entry point).
If you are developing in Devcontainer or another containerized environment, don't forget that the path to your step will differ based on where the Devcontainer files are located on your host system.
Once the step is created, any updates to the code in the mounted directory will be automatically mounted and run on future runs of that step. This enables you to rapidly expand, test, and adjust your step code without the overhead of having to push it to Sandgarden with every change.
Running local
steps is the same as running docker
steps: sand runs start --step <name> --input <input>
. Local steps can also be combined into workflows, but keep in mind that running those workflows also requires your local director to run its steps.
Graduating to deployment
Once you're satisfied with the performance and functionality of a step, you can push it as a regular step by using the normal sand steps push docker
command. The only changes you'll need to make to the command line are:
- Replace
local
withdocker
- Replace
--volumeMountPath
with--file
Once a step is deployed using the docker
type, it can run on any available director, local or cloud. If it is pushed to a specific cluster, it will run on any director in that cluster.