Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HWORKS-565] fix upload #208

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions python/hsml/core/dataset_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ def upload(

```python

import hopsworks
from hsml.core import dataset_api

project = hopsworks.login()

dataset_api = project.get_dataset_api()
dataset_api = dataset_api.DatasetApi()
javierdlrm marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down Expand Up @@ -309,6 +307,22 @@ def chmod(self, remote_path, permissions):
"PUT", path_params, headers=headers, query_params=query_params
)

def exists(self, path: str):
"""Check if a file exists in the Hopsworks Filesystem.

# Arguments
path: path to check
# Returns
`bool`: True if exists, otherwise False
# Raises
`RestAPIError`: If unable to check existence for the path
"""
try:
self._get(path)
javierdlrm marked this conversation as resolved.
Show resolved Hide resolved
return True
except RestAPIError:
return False

def mkdir(self, remote_path):
"""Path to create in datasets.

Expand Down
Loading