diff --git a/python/hopsworks/core/dataset_api.py b/python/hopsworks/core/dataset_api.py index c18f71f9e..34c02576d 100644 --- a/python/hopsworks/core/dataset_api.py +++ b/python/hopsworks/core/dataset_api.py @@ -388,3 +388,63 @@ 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): + """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 + # Raises + `RestAPIError`: If unable to perform the copy + """ + _client = client.get_instance() + path_params = ["project", self._project_id, "dataset", path] + query_params = { + "action": "copy", + "destination_path": destination_path, + } + _client._send_request( + "POST", path_params, query_params=query_params + )["attributes"]["path"] + + def move(self, source_path: str, destination_path: str): + """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 + # Raises + `RestAPIError`: If unable to perform the move + """ + _client = client.get_instance() + path_params = ["project", self._project_id, "dataset", path] + query_params = { + "action": "move", + "destination_path": destination_path, + } + _client._send_request( + "POST", path_params, query_params=query_params + )["attributes"]["path"] \ No newline at end of file