diff --git a/README.md b/README.md index 609d976..3393911 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Compiled images for all templates can be found in our [ghcr.io registry](https:/ ### ImageSpec vs Dockerfile -Flytekit uses the `basic-template-imagespec` template by default when you initialize a new project with `pyflyte init`. That template uses [ImageSpec](https://docs.flyte.org/projects/cookbook/en/latest/auto_examples/customizing_dependencies/image_spec.html#image-spec-example), which builds Docker images without a Dockerfile, so doesn't contain a Dockerfile or `docker-build.sh` script. +Flytekit uses the `basic-template-imagespec` template by default when you initialize a new project with `pyflyte init`. That template uses [ImageSpec](https://docs.flyte.org/en/latest/user_guide/customizing_dependencies/imagespec.html), which builds Docker images without a Dockerfile, so doesn't contain a Dockerfile or `docker-build.sh` script. However, some templates in this repository contain a Dockerfile and `docker-build.sh` script that you can use to build a Docker image for your Flyte project: diff --git a/basic-template-dockerfile/cookiecutter.json b/basic-template-dockerfile/cookiecutter.json new file mode 100644 index 0000000..df588ec --- /dev/null +++ b/basic-template-dockerfile/cookiecutter.json @@ -0,0 +1,3 @@ +{ + "project_name": "basic_example_dockerfile" +} diff --git a/simple-example/{{cookiecutter.project_name}}/.gitignore b/basic-template-dockerfile/{{cookiecutter.project_name}}/.gitignore similarity index 100% rename from simple-example/{{cookiecutter.project_name}}/.gitignore rename to basic-template-dockerfile/{{cookiecutter.project_name}}/.gitignore diff --git a/simple-example/{{cookiecutter.project_name}}/Dockerfile b/basic-template-dockerfile/{{cookiecutter.project_name}}/Dockerfile similarity index 95% rename from simple-example/{{cookiecutter.project_name}}/Dockerfile rename to basic-template-dockerfile/{{cookiecutter.project_name}}/Dockerfile index 71425fb..c848bb8 100644 --- a/simple-example/{{cookiecutter.project_name}}/Dockerfile +++ b/basic-template-dockerfile/{{cookiecutter.project_name}}/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-slim-buster +FROM python:3.10-slim-buster WORKDIR /root ENV VENV /opt/venv diff --git a/simple-example/{{cookiecutter.project_name}}/LICENSE b/basic-template-dockerfile/{{cookiecutter.project_name}}/LICENSE similarity index 100% rename from simple-example/{{cookiecutter.project_name}}/LICENSE rename to basic-template-dockerfile/{{cookiecutter.project_name}}/LICENSE diff --git a/simple-example/{{cookiecutter.project_name}}/README.md b/basic-template-dockerfile/{{cookiecutter.project_name}}/README.md similarity index 61% rename from simple-example/{{cookiecutter.project_name}}/README.md rename to basic-template-dockerfile/{{cookiecutter.project_name}}/README.md index adc77a9..a5417e1 100644 --- a/simple-example/{{cookiecutter.project_name}}/README.md +++ b/basic-template-dockerfile/{{cookiecutter.project_name}}/README.md @@ -7,5 +7,19 @@ A template for the recommended layout of a Flyte enabled repository for code wri To get up and running with your Flyte project, we recommend following the [Flyte getting started guide](https://docs.flyte.org/en/latest/getting_started.html). +This project includes a script `docker_build.sh` that you can use to build a +Docker image for your Flyte project. + +``` +# help +./docker_build.sh -h + +# build an image with defaults +./docker_build.sh + +# build an image with custom values +./docker_build.sh -p {{ cookiecutter.project_name }} -r -v +``` + We recommend using a git repository to version this project, so that you can use the git sha to version your Flyte workflows. diff --git a/simple-example/{{cookiecutter.project_name}}/docker_build.sh b/basic-template-dockerfile/{{cookiecutter.project_name}}/docker_build.sh similarity index 100% rename from simple-example/{{cookiecutter.project_name}}/docker_build.sh rename to basic-template-dockerfile/{{cookiecutter.project_name}}/docker_build.sh diff --git a/simple-example/{{cookiecutter.project_name}}/requirements.txt b/basic-template-dockerfile/{{cookiecutter.project_name}}/requirements.txt similarity index 100% rename from simple-example/{{cookiecutter.project_name}}/requirements.txt rename to basic-template-dockerfile/{{cookiecutter.project_name}}/requirements.txt diff --git a/simple-example/{{cookiecutter.project_name}}/workflows/__init__.py b/basic-template-dockerfile/{{cookiecutter.project_name}}/workflows/__init__.py similarity index 100% rename from simple-example/{{cookiecutter.project_name}}/workflows/__init__.py rename to basic-template-dockerfile/{{cookiecutter.project_name}}/workflows/__init__.py diff --git a/simple-example/{{cookiecutter.project_name}}/workflows/example.py b/basic-template-dockerfile/{{cookiecutter.project_name}}/workflows/example.py similarity index 65% rename from simple-example/{{cookiecutter.project_name}}/workflows/example.py rename to basic-template-dockerfile/{{cookiecutter.project_name}}/workflows/example.py index 1a01fb6..d8d9850 100644 --- a/simple-example/{{cookiecutter.project_name}}/workflows/example.py +++ b/basic-template-dockerfile/{{cookiecutter.project_name}}/workflows/example.py @@ -1,31 +1,32 @@ -"""A simple Flyte example.""" +"""A basic Flyte project template that uses a Dockerfile""" import typing from flytekit import task, workflow -@task +@task() def say_hello(name: str) -> str: - """A simple Flyte task to say "hello". + """A simple Flyte task to say "Hello". - The @task decorator allows Flyte to use this function as a Flyte task, which - is executed as an isolated, containerized unit of compute. + The @task decorator allows Flyte to use this function as a Flyte task, + which is executed as an isolated, containerized unit of compute. """ - return f"hello {name}!" + return f"Hello, {name}!" -@task +@task() def greeting_length(greeting: str) -> int: """A task the counts the length of a greeting.""" return len(greeting) + @workflow -def wf(name: str = "union") -> typing.Tuple[str, int]: +def wf(name: str = "world") -> typing.Tuple[str, int]: """Declare workflow called `wf`. - The @workflow decorator defines an execution graph that is composed of tasks - and potentially sub-workflows. In this simple example, the workflow is - composed of just one task. + The @workflow decorator defines an execution graph that is composed of + tasks and potentially sub-workflows. In this simple example, the workflow + is composed of just one task. There are a few important things to note about workflows: - Workflows are a domain-specific language (DSL) for creating execution @@ -40,6 +41,6 @@ def wf(name: str = "union") -> typing.Tuple[str, int]: if __name__ == "__main__": - # Execute the workflow, simply by invoking it like a function and passing in + # Execute the workflow by invoking it like a function and passing in # the necessary parameters - print(f"Running wf() { wf(name='passengers') }") + print(f"Running wf() {wf(name='passengers')}") diff --git a/simple-example/cookiecutter.json b/simple-example/cookiecutter.json deleted file mode 100644 index aea629b..0000000 --- a/simple-example/cookiecutter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "project_name": "flyte_example" -} diff --git a/templates.json b/templates.json index 0ea3f0b..5e07ce8 100644 --- a/templates.json +++ b/templates.json @@ -1,7 +1,7 @@ [ {"template_name": "mnist-training", "workflow_name": "mnist_workflow_cpu"}, {"template_name": "mnist-training", "workflow_name": "mnist_workflow_gpu"}, - {"template_name": "simple-example", "workflow_name": "wf"}, + {"template_name": "basic-template-dockerfile", "workflow_name": "wf"}, {"template_name": "wine-classification", "workflow_name": "training_workflow"}, {"template_name": "basic-template-imagespec", "workflow_name": "wf"}, {"template_name": "hello-world", "workflow_name": "hello_world_wf"}