Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into peeter/update-wine-ex…
Browse files Browse the repository at this point in the history
…ample-to-imagespec

Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com>
  • Loading branch information
ppiegaze committed May 29, 2024
2 parents f34ee82 + d7f828a commit 5c7bc35
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 3 additions & 0 deletions basic-template-dockerfile/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"project_name": "basic_example_dockerfile"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim-buster
FROM python:3.10-slim-buster

WORKDIR /root
ENV VENV /opt/venv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <REGISTRY> -v <VERSION>
```

We recommend using a git repository to version this project, so that you can
use the git sha to version your Flyte workflows.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')}")
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# {{ cookiecutter.project_name }}

A template for the recommended layout of a Flyte enabled repository for code written in python using [flytekit](https://docs.flyte.org/projects/flytekit/en/latest/).
A template for the recommended layout of a Flyte enabled repository for code written in python using [flytekit](https://docs.flyte.org/en/latest/api/flytekit/docs_index.html).

## Usage

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).
[Flyte getting started guide](https://docs.flyte.org/en/latest/getting_started_with_workflow_development/index.html).
3 changes: 0 additions & 3 deletions simple-example/cookiecutter.json

This file was deleted.

2 changes: 1 addition & 1 deletion templates.json
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down

0 comments on commit 5c7bc35

Please sign in to comment.