Add artifact upload format options (#249)

This commit is contained in:
pollfly 2022-05-10 13:03:52 +03:00 committed by GitHub
parent 26335830a0
commit 2db95bbf3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,8 @@ A few examples of artifacts are:
## Artifacts
### Logging Artifacts
To log any type of artifact to a Task, use the `upload_artifact()` method. For example:
To log any type of artifact to a Task, use the [`upload_artifact`](../references/sdk/task.md#upload_artifact) method.
For example:
* Upload a local file containing the preprocessing results of the data.
```python
@ -24,11 +25,26 @@ task.upload_artifact(name='data', artifact_object='/path/to/preprocess_data.csv'
```python
task.upload_artifact(name='folder', artifact_object='/path/to/folder/')
```
* Upload an instance of an object, Numpy / Pandas / PIL (converted to npz / csv.gz / jpg formats accordingly). If the
object type is unknown, it is pickled and uploaded.
* Serialize and upload a Python object. ClearML automatically chooses the file format based on the objects type, or you
can explicitly specify the format as follows:
* dict - `.json` (default), `.yaml`
* pandas.DataFrame - `.csv.gz` (default), `.parquet`, `.feather`, `.pickle`
* numpy.ndarray - `.npz` (default), `.csv.gz`
* PIL.Image - Any PIL-supported extensions (default `.png`)
For example:
```python
person_dict = {'name': 'Erik', 'age': 30}
task.upload_artifact(name='person dictionary', artifact_object=person_dict)
# upload as JSON artifact
task.upload_artifact(name='person dictionary json', artifact_object=person_dict)
# upload as YAML artifact
task.upload_artifact(
name='person dictionary yaml',
artifact_object=person_dict,
extension_name="yaml"
)
```
See more details in the artifacts [example](../guides/reporting/artifacts.md).