Skip to content

Use a dataitem

The common Dataitem object methods apply across dataitem kinds. They let you persist or refresh an entity and handle its files.

Persist and refresh

These methods interact with the entity in the backend or locally.

update

Update the entity in the backend.

Returns:

Type Description
ContextEntity

Entity updated.

export

Export object as a YAML file in the context folder.

Returns:

Type Description
str

Exported filepath.

refresh

Refresh object from backend.

Returns:

Type Description
ContextEntity

Entity refreshed.

File I/O

Use these methods to handle dataitem files.

as_file

Download the entity's files to a temporary local directory.

Returns:

Type Description
list[str]

Paths to the downloaded files.

download

Download the entity's files to a local destination.

Parameters:

Name Type Description Default
destination str

Local destination directory. If omitted, use the project context directory for this entity type.

None
overwrite bool

Whether to overwrite existing files.

False

Returns:

Type Description
str

Destination path returned by the store.

upload

Upload local files to the entity's storage path.

Parameters:

Name Type Description Default
source SourcesOrListOfSources

Local file or files to upload.

required
keep_dir_structure bool

Whether to preserve the source directory structure.

False

Raises:

Type Description
EntityErrorFileNotFound

If a source file does not exist.

EntityError

If the upload fails for another supported storage or filesystem error.

Kind-specific methods

The table and croissant kinds add methods for working with their data. See the dataitem kind references.