diff --git a/docs/fundamentals/artifacts.md b/docs/fundamentals/artifacts.md index 276990cb..03cd58e8 100644 --- a/docs/fundamentals/artifacts.md +++ b/docs/fundamentals/artifacts.md @@ -53,7 +53,7 @@ preprocess_task = Task.get_task(task_id='the_preprocessing_task_id') local_csv = preprocess_task.artifacts['data'].get_local_copy() ``` -See more details in the using artifacts [example](https://github.com/allegroai/clearml/blob/master/examples/reporting/using_artifacts_example.py). +See more details in the using artifacts [example](../guides/reporting/using_artifacts.md). ### List of Supported Artifacts diff --git a/docs/guides/reporting/using_artifacts.md b/docs/guides/reporting/using_artifacts.md new file mode 100644 index 00000000..e1962d98 --- /dev/null +++ b/docs/guides/reporting/using_artifacts.md @@ -0,0 +1,41 @@ +--- +title: Using Artifacts +--- + +The [using_artifacts_example](https://github.com/allegroai/clearml/blob/master/examples/reporting/using_artifacts_example.py) +script demonstrates uploading a data file to a task as an artifact and then accessing and utilizing the artifact in a different task. + +When the script runs it creates two tasks, `create artifact` and `use artifact from other task`, both of which are associated +with the `examples` project. The first task creates and uploads the artifact and the second task accesses the first task’s +artifact and utilizes it. + +## Task 1: Uploading an Artifact + +The first task uploads a data file as an artifact using the [`Task.upload_artifact`](../../references/sdk/task.md#upload_artifact) +method, inputting the artifact’s name and the location of the file. + +```python +task1.upload_artifact(name='data file', artifact_object='data_samples/sample.json') +``` + +The task is then closed, using the [`Task.close`](../../references/sdk/task.md#close) method, so another task can be +initialized in the same script. + +Artifact details (location and size) can be viewed in ClearML’s **web UI > experiment details > ARTIFACTS tab > OTHER section**. + +![Artifacts in WebApp](../../img/examples_using_artifacts_1.png) + +## Task 2: Accessing an Artifact + +After the second task is initialized, the script uses the [`Task.get_task`](../../references/sdk/task.md#taskget_task) +class method to get the first task and access its artifacts, specifically the `data file` artifact. The `get_local_copy` +method downloads the files and returns a path. + +```python +preprocess_task = Task.get_task(task_name='create artifact', project_name='examples') +local_json = preprocess_task.artifacts['data file'].get_local_copy() +``` + +Task 2 then reads the contents of the downloaded artifact and prints it to screen. + + diff --git a/docs/img/examples_using_artifacts_1.png b/docs/img/examples_using_artifacts_1.png new file mode 100644 index 00000000..78bfdd09 Binary files /dev/null and b/docs/img/examples_using_artifacts_1.png differ diff --git a/sidebars.js b/sidebars.js index e3e912b1..c8e7e6c5 100644 --- a/sidebars.js +++ b/sidebars.js @@ -98,7 +98,7 @@ module.exports = { {'Optimization': ['guides/optimization/hyper-parameter-optimization/examples_hyperparam_opt']}, {'Pipelines': ['guides/pipeline/pipeline_controller']}, - {'Reporting': ['guides/reporting/explicit_reporting','guides/reporting/3d_plots_reporting', 'guides/reporting/artifacts', 'guides/reporting/clearml_logging_example', 'guides/reporting/html_reporting', + {'Reporting': ['guides/reporting/explicit_reporting','guides/reporting/3d_plots_reporting', 'guides/reporting/artifacts', 'guides/reporting/using_artifacts', 'guides/reporting/clearml_logging_example', 'guides/reporting/html_reporting', 'guides/reporting/hyper_parameters', 'guides/reporting/image_reporting', 'guides/reporting/manual_matplotlib_reporting', 'guides/reporting/media_reporting', 'guides/reporting/model_config', 'guides/reporting/pandas_reporting', 'guides/reporting/plotly_reporting', 'guides/reporting/scalar_reporting', 'guides/reporting/scatter_hist_confusion_mat_reporting', 'guides/reporting/text_reporting']},