.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_examples_apps_datapreproc_component.py:
Data Preprocessing Example Components
======================================
This is a component definition that runs the example datapreproc app.
.. code-block:: default
from typing import Dict, Optional
import torchx.specs as specs
def data_preproc(
image: str,
output_path: str,
input_path: str = "http://cs231n.stanford.edu/tiny-imagenet-200.zip",
env: Optional[Dict[str, str]] = None,
resource: Optional[str] = None,
) -> specs.AppDef:
"""Data PreProc app.
Data PreProc app.
Args:
image: Image to use
output_path: Url-like path to save the processes compressed images
input_path: Url-like path to fetch the imagenet dataset
env: Env variables to transfer to the user script
resource: String representation of the resource
dryrun: Starts the app, but does not actually perform any work.
Returns:
specs.AppDef: TorchX AppDef
"""
env = env or {}
args = [
"-m",
"torchx.examples.apps.datapreproc.datapreproc",
"--input_path",
input_path,
"--output_path",
output_path,
]
if resource:
resource_def = specs.named_resources[resource]
else:
resource_def = specs.Resource(cpu=1, gpu=0, memMB=1024)
return specs.AppDef(
name="datapreproc",
roles=[
specs.Role(
name="worker",
image=image,
entrypoint="python",
args=args,
env=env,
resource=resource_def,
)
],
)
# sphinx_gallery_thumbnail_path = '_static/img/gallery-component.png'
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.000 seconds)
.. _sphx_glr_download_examples_apps_datapreproc_component.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: component.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: component.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_