diff --git a/README.md b/README.md index 3e07257..c621b0a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,40 @@ -# Speckle Automate - Python Example +# Speckle Automate function template - Python + +This is a template repository for a Speckle Automate functions written in python +using the [specklepy](https://pypi.org/project/specklepy/) SDK to interact with Speckle data. + +This template contains the full scaffolding required to publish a function to the automate environment. +Also has some sane defaults for a development environment setups. + +## Getting started + +1. Use this template repository to create a new repository in your own / organization's profile. + +Register the function + +### Add new dependencies + +To add new python package dependencies to the project, use: +`$ poetry add pandas` + +### Change launch variables + +describe how the launch.json should be edited + +### Github Codespaces + +create new repo from template, and use the create new code + + +### Local dev environment + + + + +# Archive This is a simple example of how to use the Speckle Automate Python package to automate the creation of a Speckle stream. -## What this Speckle Function does - -This Speckle Function creates a new comment in a Speckle Model. The phrase used in the comment is configured when the Speckle Automation is created; the Speckle Automation links a Speckle Function to a Speckle Model. - -The comment is attributed to the user who registered the Function with Speckle Automate. ## Using this Speckle Function @@ -32,7 +60,7 @@ The comment is attributed to the user who registered the Function with Speckle A 1. Install the following: - [Python 3](https://www.python.org/downloads/) - [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) -1. Run `poetry install` to install the required Python packages. +1. Run `poetry shell && poetry install` to install the required Python packages. ## Building and Testing diff --git a/main.py b/main.py index 3964999..b775743 100644 --- a/main.py +++ b/main.py @@ -2,10 +2,18 @@ import typer import os from speckle_project_data import SpeckleProjectData from automate_function import FunctionInputs, automate_function +from typing_extensions import Annotated +from typing import Optional -def main(speckle_project_data: str, function_inputs: str, speckle_token: str = ""): - speckle_token = speckle_token if speckle_token else os.environ.get("SPECKLE_TOKEN") +def main( + speckle_project_data: str, + function_inputs: str, + speckle_token: Annotated[Optional[str], typer.Argument()] = None, +): + speckle_token = ( + speckle_token if speckle_token else os.environ.get("SPECKLE_TOKEN", None) + ) if not speckle_token: raise ValueError("The supplied speckle token is not valid")