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

project = hopsworks.login()

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]

mkdir#

DatasetApi.mkdir(path)

Create a directory in the Hopsworks Filesystem.

import hopsworks

project = hopsworks.login()

dataset_api = project.get_dataset_api()

directory_path = dataset_api.mkdir("Resources/my_dir")
Arguments

  • path str: path to directory

Returns

str: Path to created directory

Raises

  • RestAPIError: If unable to create the directory

[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

project = hopsworks.login()

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