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-800 and Release 3.4.3 #181

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

<groupId>com.logicalclocks</groupId>
<artifactId>hopsworks</artifactId>
<version>3.4.2</version>
<version>3.4.3</version>
</project>
79 changes: 79 additions & 0 deletions python/hopsworks/core/dataset_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,82 @@ def mkdir(self, path: str):
return _client._send_request(
"POST", path_params, headers=headers, query_params=query_params
)["attributes"]["path"]

def copy(self, source_path: str, destination_path: str, overwrite: bool = False):
"""Copy a file or directory in the Hopsworks Filesystem.

```python

import hopsworks

project = hopsworks.login()

dataset_api = project.get_dataset_api()

directory_path = dataset_api.copy("Resources/myfile.txt", "Logs/myfile.txt")

```
# Arguments
source_path: the source path to copy
destination_path: the destination path
overwrite: overwrite destination if exists
# Raises
`RestAPIError`: If unable to perform the copy
"""
if self.exists(destination_path):
if overwrite:
self.remove(destination_path)
else:
raise DatasetException(
"{} already exists, set overwrite=True to overwrite it".format(
destination_path
)
)

_client = client.get_instance()
path_params = ["project", self._project_id, "dataset", source_path]
query_params = {
"action": "copy",
"destination_path": destination_path,
}
_client._send_request("POST", path_params, query_params=query_params)

def move(self, source_path: str, destination_path: str, overwrite: bool = False):
"""Move a file or directory in the Hopsworks Filesystem.

```python

import hopsworks

project = hopsworks.login()

dataset_api = project.get_dataset_api()

directory_path = dataset_api.move("Resources/myfile.txt", "Logs/myfile.txt")

```
# Arguments
source_path: the source path to move
destination_path: the destination path
overwrite: overwrite destination if exists
# Raises
`RestAPIError`: If unable to perform the move
"""

if self.exists(destination_path):
if overwrite:
self.remove(destination_path)
else:
raise DatasetException(
"{} already exists, set overwrite=True to overwrite it".format(
destination_path
)
)

_client = client.get_instance()
path_params = ["project", self._project_id, "dataset", source_path]
query_params = {
"action": "move",
"destination_path": destination_path,
}
_client._send_request("POST", path_params, query_params=query_params)
2 changes: 1 addition & 1 deletion python/hopsworks/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#

__version__ = "3.4.2"
__version__ = "3.4.3"
Loading