Skip to content

Commit

Permalink
apply changes from @cosmicBboy flytesnacks PR flyteorg/flytesnacks#1736
Browse files Browse the repository at this point in the history
… to docs contributing guide, plus make additional changes

Signed-off-by: nikki everett <[email protected]>
  • Loading branch information
nikki everett committed Oct 9, 2024
1 parent da2ce74 commit dd1d27f
Showing 1 changed file with 54 additions and 51 deletions.
105 changes: 54 additions & 51 deletions docs/community/contribute_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ new example project.
In the `flytesnacks` root directory, run the following command to create an example project:
```{prompt} bash
./scripts/create-example-project new_example_project
./scripts/create-example-project.sh new_example_project
```
This will create a new directory under `examples`:
Expand All @@ -103,8 +103,7 @@ examples/new_example_project
├── new_example_project
│   ├── __init__.py
│   └── example.py
├── requirements.in
└── requirements.txt
└── requirements.in
```
````
Expand Down Expand Up @@ -170,7 +169,9 @@ packaged, but `flytesnacks` also supports examples written in `.ipynb` and
- `.md`: When a piece of documentation doesn't require testable or packaged
flyte tasks/workflows, an example page can be written as a MyST Markdown file.

**Note:** If you want to add Markdown files to a user guide example project, add them to the [flyte repository](https://github.com/flyteorg/flyte/tree/master/docs/user_guide) instead.
```{note}
If you want to add Markdown files to a user guide example project, add them to the [flyte repository](https://github.com/flyteorg/flyte/tree/master/docs/user_guide) instead.
```

### Writing a README

Expand Down Expand Up @@ -201,11 +202,15 @@ Refer to any subdirectory in the `examples` directory

### Test your code

If the example code can be run locally, just use `python <my_file>.py` to run it.
If the example code can be run locally, you can use `pyflyte run` to test it:

```{prompt} bash
pyflyte run <python_file>.py <task_or_workflow_name> --<arg1> <arg1_value> --<arg2> <arg2_value> ...
```

#### Testing on a cluster

Install {doc}`flytectl <flytectl:index>`, the commandline interface for flyte.
Install {doc}`flytectl <flytectl:index>`, the command line interface for flyte.

:::{note}
Learn more about installation and configuration of Flytectl [here](https://docs.flyte.org/en/latest/flytectl/docs_index.html).
Expand All @@ -219,33 +224,28 @@ flytectl demo start

#### Testing the `basics` project examples on a local demo cluster

In this example, we'll build the `basics` project:
In this example, we'll build the `basics` project.

Change to the basics directory:

```{prompt} bash
# from flytesnacks root directory
cd examples/basics
```

Build the container:

```{prompt} bash
docker build . --tag "basics:v1" -f Dockerfile
```

Package the examples by running:
Build and push the container to the local Docker registry provided by the demo cluster:

```{prompt} bash
pyflyte --pkgs basics package --image basics:v1 -f
docker build . --tag "localhost:30000/basics:v1" -f Dockerfile --push
```

Register the examples by running
Run a workflow in the local demo cluster by specifying the `--image` flag
and passing the `--remote` flag:

```{prompt} bash
flytectl register files \
-p flytesnacks \
-d development \
--archive flyte-package.tgz \
--version v1
pyflyte run --remote \
--image localhost:30000/basics:v1 \
basics/hello_world.py hello_world_wf
```

Visit `https://localhost:30081/console` to view the Flyte console, which consists
Expand All @@ -263,30 +263,31 @@ pip install pip-tools

:::

If you've updated the dependencies of the project, update the `requirements.txt`
file by running:
If the project uses pinned dependencies in a `requirements.in` file, run the `pip-compile` command to create a new pinned `requirements.txt` file:

```{prompt} bash
pip-compile requirements.in --upgrade --verbose --resolver=backtracking
```

#### Rebuild the image

If you've updated the source code or dependencies of the project, and rebuild
If you've updated the source code or dependencies of the project, rebuild
the image with:

```{prompt} bash
docker build . --tag "basics:v2" -f core/Dockerfile
pyflyte --pkgs basics package --image basics:v2 -f
flytectl register files \
-p flytesnacks \
-d development \
--archive flyte-package.tgz \
--version v2
docker build . --tag "localhost:30000/basics:v2" -f Dockerfile --push
```

Next, run the workflow again with the new image:

```{prompt} bash
pyflyte run --remote \
--image localhost:30000/basics:v2 \
basics/hello_world.py hello_world_wf
```

Refer to {ref}`this guide <getting_started_package_register>`
if the code in itself is updated and requirements.txt is the same.
if the code itself is updated and requirements.txt is the same.

### Pre-commit hooks

Expand All @@ -307,37 +308,41 @@ are configured as git hooks in `pre-commit`. Run `make fmt` to format your code.
We use [codespell](https://github.com/codespell-project/codespell) to catch common misspellings. Run
`make spellcheck` to spell-check the changes.

### Update documentation pages
### Update tutorials and integrations examples documentation pages

The `docs/conf.py` contains the Sphinx configuration for building the
`flytesnacks` documentation.
The `docs/conf.py` file in the flytesnacks repository contains the Sphinx configuration for building the `flytesnacks` documentation.

At build time, the `flytesnacks` Sphinx build system will convert the tutorials and integrations examples in the `examples` directory into `docs/auto_examples` and make them available in the documentation.

::::{important}

The docs build system will convert the `README.md` files in each tutorials and example integration project
project into a `index.md` file, so you can reference the root page of each
example project, e.g., in MyST Markdown format, you can write a table-of-contents
directive like so:
The docs build system will convert the `README.md` files in each tutorial and example integration project into an `index.md` file, allowing you to reference the root page of each
example project in MyST Markdown format.

::::

If you've created a new tutorial or integration example project, you'll need to add its `index` page
to the table of contents in `docs/tutorials/index.md` or `docs/integrations/index.md` and update the appropriate `list-table` directive in the file to make sure the example shows up in the documentation:

:::{code-block}

```{list-table}
:header-rows: 0
:widths: 20 30
* - {doc}`Airflow agent </auto_examples/airflow_agent/index>`
- Run Airflow jobs in your workflows with the Airflow agent.
...
```

...

```{toc}
/auto_examples/bigquery_agent/index
```

:::

::::

If you've created a new tutorial or integration example project, you'll need to add its `index` page
to the table of contents in `docs/index.md` to make sure the project
shows up in the documentation. Additionally, you'll need to update the appropriate
`list-table` directive in `docs/tutorials/index.md`, or
`docs/integrations/index.md` so that it shows up in the respective section of the
documentation.

### Build the documentation locally

Verify that the code and documentation look as expected:
Expand All @@ -355,10 +360,8 @@ Verify that the code and documentation look as expected:

### Create a pull request

Create the pull request in the flytesnacks repository, then ensure that the docs are rendered correctly by clicking on the documentation check.
Create the pull request in the flytesnacks repository, then ensure that the docs are rendered correctly by clicking on the documentation check:

```{image} https://github.com/user-attachments/assets/581330cc-c9ab-418d-a9ae-bb3c346603ba
:alt: Docs link in a PR
```

You can refer to [this PR](https://github.com/flyteorg/flytesnacks/pull/332) for the exact changes required.

0 comments on commit dd1d27f

Please sign in to comment.