Skip to content

Datasets API#

Handle#

[source]

get_dataset_api#

Project.get_dataset_api()

Get the dataset api for the project.

Returns

DatasetApi: The Datasets Api handle


Methods#

[source]

download#

DatasetApi.download(path, local_path=None, overwrite=False)

Download file from Hopsworks Filesystem to the current working directory.

import hopsworks

connection = hopsworks.connection()

project = connection.get_project()

dataset_api = project.get_dataset_api()

downloaded_file_path = dataset_api.download("Resources/my_local_file.txt")
Arguments

  • path str: path in Hopsworks filesystem to the file
  • local_path Optional[str]: path where to download the file in the local filesystem
  • overwrite bool: overwrite local file if exists

Returns

str: Path to downloaded file

Raises

  • RestAPIError: If unable to download the file

[source]

exists#

DatasetApi.exists(path)

Check if a file exists in the Hopsworks Filesystem.

Arguments

  • path str: path to check

Returns

bool: True if exists, otherwise False

Raises

  • RestAPIError: If unable to check existence for the path

[source]

remove#

DatasetApi.remove(path)

Remove a path in the Hopsworks Filesystem.

Arguments

  • path str: path to remove

Raises

  • RestAPIError: If unable to remove the path

[source]

upload#

DatasetApi.upload(local_path, upload_path, overwrite=False)

Upload a file to the Hopsworks filesystem.

import hopsworks

connection = hopsworks.connection()

project = connection.get_project()

dataset_api = project.get_dataset_api()

uploaded_file_path = dataset_api.upload("my_local_file.txt", "Resources")
Arguments

  • local_path str: local path to file to upload
  • upload_path str: path to directory where to upload the file in Hopsworks Filesystem
  • overwrite bool: overwrite file if exists

Returns

str: Path to uploaded file

Raises

  • RestAPIError: If unable to upload the file