@@ -400,25 +400,27 @@ def _upload_request(self, params, path, file_name, chunk):
400
400
)
401
401
402
402
def _get (self , path : str ):
403
- """Get dataset.
403
+ """Get dataset metadata .
404
404
405
- :param path: path to check
406
- :type path: str
407
- :return: dataset metadata
408
- :rtype: dict
405
+ # Arguments
406
+ path: path to check
407
+ # Returns
408
+ ` dict`: dataset metadata
409
409
"""
410
410
_client = client .get_instance ()
411
411
path_params = ["project" , _client ._project_id , "dataset" , path ]
412
412
headers = {"content-type" : "application/json" }
413
413
return _client ._send_request ("GET" , path_params , headers = headers )
414
414
415
415
def get (self , path : str ):
416
- """Get dataset.
416
+ """**Deprecated**
417
+
418
+ Get dataset metadata.
417
419
418
- :param path: path to check
419
- :type path: str
420
- :return: dataset metadata
421
- :rtype: dict
420
+ # Arguments
421
+ path: path to check
422
+ # Returns
423
+ ` dict`: dataset metadata
422
424
"""
423
425
return self ._get (path )
424
426
@@ -429,8 +431,6 @@ def exists(self, path: str):
429
431
path: path to check
430
432
# Returns
431
433
`bool`: True if exists, otherwise False
432
- # Raises
433
- `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
434
434
"""
435
435
try :
436
436
self ._get (path )
@@ -439,12 +439,14 @@ def exists(self, path: str):
439
439
return False
440
440
441
441
def path_exists (self , remote_path : str ):
442
- """Check if a path exists in datasets.
442
+ """**Deprecated**, use `exists` instead.
443
+
444
+ Check if a path exists in datasets.
443
445
444
- :param remote_path: path to check
445
- :type remote_path: str
446
- :return: boolean whether path exists
447
- :rtype: bool
446
+ # Arguments
447
+ remote_path: path to check
448
+ # Returns
449
+ ` bool`: True if exists, otherwise False
448
450
"""
449
451
return self .exists (remote_path )
450
452
@@ -462,7 +464,9 @@ def remove(self, path: str):
462
464
return _client ._send_request ("DELETE" , path_params )
463
465
464
466
def rm (self , remote_path : str ):
465
- """Remove a path in the Hopsworks Filesystem.
467
+ """**Deprecated**, use `remove` instead.
468
+
469
+ Remove a path in the Hopsworks Filesystem.
466
470
467
471
# Arguments
468
472
remote_path: path to remove
@@ -526,6 +530,7 @@ def copy(self, source_path: str, destination_path: str, overwrite: bool = False)
526
530
destination_path: the destination path
527
531
overwrite: overwrite destination if exists
528
532
# Raises
533
+ `hopsworks.client.exceptions.DatasetException`: If the destination path already exists and overwrite is not set to True
529
534
`hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
530
535
"""
531
536
if self .exists (destination_path ):
@@ -571,6 +576,7 @@ def move(self, source_path: str, destination_path: str, overwrite: bool = False)
571
576
destination_path: the destination path
572
577
overwrite: overwrite destination if exists
573
578
# Raises
579
+ `hopsworks.client.exceptions.DatasetException`: If the destination path already exists and overwrite is not set to True
574
580
`hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
575
581
"""
576
582
if self .exists (destination_path ):
@@ -625,7 +631,18 @@ def upload_feature_group(self, feature_group, path, dataframe):
625
631
chunk_number += 1
626
632
627
633
@usage .method_logger
628
- def list_files (self , path , offset , limit ):
634
+ def list_files (self , path : str , offset : int , limit : int ):
635
+ """**Deprecated**
636
+
637
+ List contents of a directory in the Hopsworks Filesystem.
638
+
639
+ # Arguments
640
+ path: path to the directory to list the contents of.
641
+ offset: the number of Inodes to skip.
642
+ limit: max number of the returned Inodes.
643
+ # Returns
644
+ `tuple[int, list[hopsworks.core.inode.Inode]]`: count of Inodes in the directory and the list of them.
645
+ """
629
646
_client = client .get_instance ()
630
647
path_params = [
631
648
"project" ,
@@ -645,21 +662,33 @@ def list_files(self, path, offset, limit):
645
662
return inode_lst ["count" ], inode .Inode .from_response_json (inode_lst )
646
663
647
664
@usage .method_logger
648
- def list (self , remote_path , sort_by = None , offset = 0 , limit = 1000 ):
649
- """List all files in a directory in datasets.
650
-
651
- :param remote_path: path to list
652
- :type remote_path: str
653
- :param sort_by: sort string
654
- :type sort_by: str
655
- :param limit: max number of returned files
656
- :type limit: int
665
+ def list (
666
+ self ,
667
+ remote_path : str ,
668
+ sort_by : str | None = None ,
669
+ offset : int = 0 ,
670
+ limit : int = 1000 ,
671
+ ):
672
+ """**Deprecated**
673
+
674
+ List contents of a directory in the Hopsworks Filesystem.
675
+
676
+ # Arguments
677
+ remote_path: path to the directory to list the contents of.
678
+ sort_by: sort string, for example `"ID:asc"`.
679
+ offset: the number of entities to skip.
680
+ limit: max number of the returned entities.
657
681
"""
658
682
# this method is probably to be merged with list_files
659
683
# they seem to handle paths differently and return different results, which prevents the merge at the moment (2024-09-03), due to the requirement of backwards-compatibility
660
684
_client = client .get_instance ()
661
685
path_params = ["project" , _client ._project_id , "dataset" , remote_path ]
662
- query_params = {"action" : "listing" , "sort_by" : sort_by , "limit" : limit , "offset" : offset }
686
+ query_params = {
687
+ "action" : "listing" ,
688
+ "sort_by" : sort_by ,
689
+ "limit" : limit ,
690
+ "offset" : offset ,
691
+ }
663
692
headers = {"content-type" : "application/json" }
664
693
return _client ._send_request (
665
694
"GET" , path_params , headers = headers , query_params = query_params
@@ -684,13 +713,16 @@ def read_content(self, path: str, dataset_type: str = "DATASET"):
684
713
685
714
return _client ._send_request ("GET" , path_params , query_params , stream = True )
686
715
687
- def chmod (self , remote_path , permissions ):
688
- """Chmod operation on file or directory in datasets .
716
+ def chmod (self , remote_path : str , permissions : str ):
717
+ """Change permissions of a file or a directory in the Hopsworks Filesystem .
689
718
690
- :param remote_path: path to chmod
691
- :type remote_path: str
692
- :param permissions: permissions string, for example u+x
693
- :type permissions: str
719
+ # Arguments
720
+ remote_path: path to change the permissions of.
721
+ permissions: permissions string, for example `"u+x"`.
722
+ # Returns
723
+ `dict`: the updated dataset metadata
724
+ # Raises
725
+ `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
694
726
"""
695
727
_client = client .get_instance ()
696
728
path_params = ["project" , _client ._project_id , "dataset" , remote_path ]
@@ -721,6 +753,9 @@ def _archive(
721
753
722
754
# Returns
723
755
`bool`: whether the operation completed in the specified timeout; if non-blocking, always returns True.
756
+
757
+ # Raises
758
+ `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
724
759
"""
725
760
726
761
_client = client .get_instance ()
@@ -789,6 +824,9 @@ def unzip(
789
824
790
825
# Returns
791
826
`bool`: whether the operation completed in the specified timeout; if non-blocking, always returns True.
827
+
828
+ # Raises
829
+ `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
792
830
"""
793
831
return self ._archive (remote_path , block = block , timeout = timeout , action = "unzip" )
794
832
@@ -809,6 +847,9 @@ def zip(
809
847
810
848
# Returns
811
849
`bool`: whether the operation completed in the specified timeout; if non-blocking, always returns True.
850
+
851
+ # Raises
852
+ `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
812
853
"""
813
854
return self ._archive (
814
855
remote_path ,
@@ -820,18 +861,18 @@ def zip(
820
861
821
862
# region Dataset Tags
822
863
823
- def add (self , path , name , value ):
824
- """Attach a name/value tag to a model.
864
+ def add (self , path : str , name : str , value : str ):
865
+ """**Deprecated**
866
+
867
+ Attach a name/value tag to a model.
825
868
826
869
A tag consists of a name/value pair. Tag names are unique identifiers.
827
870
The value of a tag can be any valid json - primitives, arrays or json objects.
828
871
829
- :param path: path to add the tag
830
- :type path: str
831
- :param name: name of the tag to be added
832
- :type name: str
833
- :param value: value of the tag to be added
834
- :type value: str
872
+ # Arguments
873
+ path: path to add the tag
874
+ name: name of the tag to be added
875
+ value: value of the tag to be added
835
876
"""
836
877
_client = client .get_instance ()
837
878
path_params = [
@@ -847,15 +888,16 @@ def add(self, path, name, value):
847
888
json_value = json .dumps (value )
848
889
_client ._send_request ("PUT" , path_params , headers = headers , data = json_value )
849
890
850
- def delete (self , path , name ):
851
- """Delete a tag.
891
+ def delete (self , path : str , name : str ):
892
+ """**Deprecated**
893
+
894
+ Delete a tag.
852
895
853
896
Tag names are unique identifiers.
854
897
855
- :param path: path to delete the tags
856
- :type path: str
857
- :param name: name of the tag to be removed
858
- :type name: str
898
+ # Arguments
899
+ path: path to delete the tags
900
+ name: name of the tag to be removed
859
901
"""
860
902
_client = client .get_instance ()
861
903
path_params = [
@@ -869,17 +911,19 @@ def delete(self, path, name):
869
911
]
870
912
_client ._send_request ("DELETE" , path_params )
871
913
872
- def get_tags (self , path , name : str = None ):
873
- """Get the tags.
914
+ def get_tags (self , path : str , name : str | None = None ):
915
+ """**Deprecated**
916
+
917
+ Get the tags.
874
918
875
919
Gets all tags if no tag name is specified.
876
920
877
- :param path: path to get the tags
878
- :type path: str
879
- :param name: tag name
880
- :type name: str
881
- :return: dict of tag name/values
882
- :rtype: dict
921
+ # Arguments
922
+ path: path to get the tags
923
+ name: tag name
924
+
925
+ # Returns
926
+ ` dict`: tag names and values
883
927
"""
884
928
_client = client .get_instance ()
885
929
path_params = [
0 commit comments