Drive

class lightning.app.storage.drive.Drive(id, allow_duplicates=False, component_name=None, root_folder=None)[source]

Bases: object

The Drive object provides a shared space to write and read files from.

When the drive object is passed from one component to another, a copy is made and ownership is transferred to the new component.

Parameters:
  • id (str) – Unique identifier for this Drive.

  • allow_duplicates (bool) – Whether to enable files duplication between components.

  • component_name (Optional[str]) – The component name which owns this drive. When not provided, it is automatically inferred by Lightning.

  • root_folder (Optional[str]) – This is the folder from where the Drive perceives the data (e.g this acts as a mount dir).

delete(path)[source]

This method enables to delete files under the provided path from the Drive in a blocking fashion. Only the component which added a file can delete them.

Parameters:

path (str) – The relative path you want to delete files from the Drive.

Return type:

None

get(path, component_name=None, timeout=None, overwrite=False)[source]

This method enables to get files under the provided path from the Drive in a blocking fashion.

Parameters:
  • path (str) – The relative path you want to list files from the Drive.

  • component_name (Optional[str]) – By default, the Drive get the matching files across all components. If you provide a component name, the matching is specific to this component.

  • timeout (Optional[float]) – Whether to wait for the files to be available if not created yet.

  • overwrite (bool) – Whether to override the provided path if it exists.

Return type:

None

list(path='.', component_name=None)[source]

This method enables to list files under the provided path from the Drive in a blocking fashion.

Parameters:
  • path (Optional[str]) – The relative path you want to list files from the Drive.

  • component_name (Optional[str]) – By default, the Drive lists files across all components. If you provide a component name, the listing is specific to this component.

Return type:

List[str]

put(path)[source]

This method enables to put a file to the Drive in a blocking fashion.

Parameters:

path (str) – The relative path to your files to be added to the Drive.

Return type:

None