Skip to content

Commit

Permalink
Added pypi to step decorators docs. (#119)
Browse files Browse the repository at this point in the history
* Added pypi to step decorators docs. Updated conda-vs-pypi to include information about wheel requirements for pypi packages.

* Update conda-vs-pypi.md

* Update README.md

---------

Co-authored-by: Savin <[email protected]>
  • Loading branch information
nbertagnolli and savingoyal authored May 2, 2024
1 parent d302585 commit a9f2341
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/api/step-decorators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ attaches a `@retry` and `@batch(cpu=4)` decorators to all steps of the flow.
- [`@batch`](/api/step-decorators/batch) - run on AWS Batch.
- [`@card`](/api/step-decorators/card) - enable reporting.
- [`@catch`](/api/step-decorators/catch) - catch errors.
- [`@conda`](/api/step-decorators/conda) - define libraries.
- [`@conda`](/api/step-decorators/conda) - define Conda dependencies.
- [`@pypi`](/api/step-decorators/pypi) - define PyPI dependencies.
- [`@kubernetes`](/api/step-decorators/kubernetes) - run on Kubernetes.
- [`@resources`](/api/step-decorators/resources) - request resources.
- [`@retry`](/api/step-decorators/retry) - retry errors.
Expand Down
110 changes: 110 additions & 0 deletions docs/api/step-decorators/pypi.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "d1023227",
"metadata": {},
"source": [
"# @pypi\n",
"\n",
"The `@pypi` decorator specifies what packages should be made available for a step.\n",
"\n",
"The packages are installed from [PyPI repositories](https://pypi.org/). Packages must be a wheel. For more information, see [Managing External Libraries](/scaling/dependencies)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8d5bb116",
"metadata": {
"execution": {
"iopub.execute_input": "2024-01-19T07:19:59.070862Z",
"iopub.status.busy": "2024-01-19T07:19:59.070787Z",
"iopub.status.idle": "2024-01-19T07:19:59.348157Z",
"shell.execute_reply": "2024-01-19T07:19:59.347872Z"
}
},
"outputs": [],
"source": [
"#meta:tag=hide\n",
"from functools import partial\n",
"from nbdoc.showdoc import ShowDoc\n",
"ShowDoc = partial(ShowDoc, module_nm='metaflow')\n",
"\n",
"from metaflow import pypi"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "29af6ee3",
"metadata": {
"execution": {
"iopub.execute_input": "2024-01-19T07:19:59.350675Z",
"iopub.status.busy": "2024-01-19T07:19:59.350507Z",
"iopub.status.idle": "2024-01-19T07:19:59.358078Z",
"shell.execute_reply": "2024-01-19T07:19:59.357812Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<HTMLRemove>\n",
"<h3> <code>decorator</code> <span style=\"color:Brown\">@pypi</span> <em>(...)</em><a href=\"https://github.com/Netflix/metaflow/tree/master/metaflow/plugins/pypi/pypi_decorator.py#L5\" style=\"float:right\">[source]</a></h3><strong>metaflow</strong><p><blockquote>Specifies&nbsp;the&nbsp;PyPI&nbsp;packages&nbsp;for&nbsp;the&nbsp;step.<br><br>Information&nbsp;in&nbsp;this&nbsp;decorator&nbsp;will&nbsp;augment&nbsp;any<br>attributes&nbsp;set&nbsp;in&nbsp;the&nbsp;`@pyi_base`&nbsp;flow-level&nbsp;decorator.&nbsp;Hence,<br>you&nbsp;can&nbsp;use&nbsp;`@pypi_base`&nbsp;to&nbsp;set&nbsp;packages&nbsp;required&nbsp;by&nbsp;all<br>steps&nbsp;and&nbsp;use&nbsp;`@pypi`&nbsp;to&nbsp;specify&nbsp;step-specific&nbsp;overrides.<br><br>Parameters<br>----------<br>packages&nbsp;:&nbsp;Dict[str,&nbsp;str],&nbsp;default:&nbsp;{}<br>&nbsp;&nbsp;&nbsp;&nbsp;Packages&nbsp;to&nbsp;use&nbsp;for&nbsp;this&nbsp;step.&nbsp;The&nbsp;key&nbsp;is&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;package<br>&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;the&nbsp;value&nbsp;is&nbsp;the&nbsp;version&nbsp;to&nbsp;use.<br>python&nbsp;:&nbsp;str,&nbsp;optional,&nbsp;default:&nbsp;None<br>&nbsp;&nbsp;&nbsp;&nbsp;Version&nbsp;of&nbsp;Python&nbsp;to&nbsp;use,&nbsp;e.g.&nbsp;'3.7.4'.&nbsp;A&nbsp;default&nbsp;value&nbsp;of&nbsp;None&nbsp;implies<br>&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;the&nbsp;version&nbsp;used&nbsp;will&nbsp;correspond&nbsp;to&nbsp;the&nbsp;version&nbsp;of&nbsp;the&nbsp;Python&nbsp;interpreter&nbsp;used&nbsp;to&nbsp;start&nbsp;the&nbsp;run.</blockquote></p>\n",
"</HTMLRemove>\n",
"<DocSection type=\"decorator\" name=\"pypi\" module=\"metaflow\" show_import=\"True\" heading_level=\"3\" link=\"https://github.com/Netflix/metaflow/tree/master/metaflow/plugins/pypi/pypi_decorator.py#L5\">\n",
"<SigArgSection>\n",
"<SigArg name=\"...\" />\n",
"</SigArgSection>\n",
"<Description summary=\"Specifies the PyPI packages for the step.\" extended_summary=\"Information in this decorator will augment any\\nattributes set in the `@pyi_base` flow-level decorator. Hence,\\nyou can use `@pypi_base` to set packages required by all\\nsteps and use `@pypi` to specify step-specific overrides.\" />\n",
"<ParamSection name=\"Parameters\">\n",
"\t<Parameter name=\"packages\" type=\"Dict[str, str], default: {}\" desc=\"Packages to use for this step. The key is the name of the package\\nand the value is the version to use.\" />\n",
"\t<Parameter name=\"python\" type=\"str, optional, default: None\" desc=\"Version of Python to use, e.g. '3.7.4'. A default value of None implies\\nthat the version used will correspond to the version of the Python interpreter used to start the run.\" />\n",
"</ParamSection>\n",
"</DocSection>"
],
"text/plain": [
"<nbdoc.showdoc.ShowDoc at 0x118eaf820>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ShowDoc(pypi, skip_sections='Attributes', show_import=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a84d95f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
20 changes: 20 additions & 0 deletions docs/api/step-decorators/pypi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @pypi

The `@pypi` decorator specifies what packages should be made available for a step.

The packages are installed from [PyPI repositories](https://pypi.org/). Packages must be a wheel. For more information, see [Managing External Libraries](/scaling/dependencies).

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! Instead, edit the notebook w/the location & name as this file. -->


<DocSection type="decorator" name="pypi" module="metaflow" show_import="True" heading_level="3" link="https://github.com/Netflix/metaflow/tree/master/metaflow/plugins/pypi/pypi_decorator.py#L5">
<SigArgSection>
<SigArg name="..." />
</SigArgSection>
<Description summary="Specifies the PyPI packages for the step." extended_summary="Information in this decorator will augment any\nattributes set in the `@pyi_base` flow-level decorator. Hence,\nyou can use `@pypi_base` to set packages required by all\nsteps and use `@pypi` to specify step-specific overrides." />
<ParamSection name="Parameters">
<Parameter name="packages" type="Dict[str, str], default: {}" desc="Packages to use for this step. The key is the name of the package\nand the value is the version to use." />
<Parameter name="python" type="str, optional, default: None" desc="Version of Python to use, e.g. '3.7.4'. A default value of None implies\nthat the version used will correspond to the version of the Python interpreter used to start the run." />
</ParamSection>
</DocSection>

2 changes: 1 addition & 1 deletion docs/scaling/dependencies/conda-vs-pypi.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ also handle non-Python dependencies but with more limitations compared to Conda.

Hence the choice is often simple:

- If you can find packages you need at [PyPI](https://pypi.org) and
- If you can find packages you need at [PyPI](https://pypi.org),
you can `pip install` them without trouble,
`@pypi` is a safe bet.

Expand Down

0 comments on commit a9f2341

Please sign in to comment.