Skip to content

Commit

Permalink
Rename UserRole to DatasetCollaborator in kagglesdk (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
erdalsivri authored Nov 12, 2024
1 parent 963d26e commit 68c89f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from kagglesdk.datasets.types.dataset_enums import DatasetSelectionGroup, \
DatasetSortBy, DatasetFileTypeGroup, DatasetLicenseGroup
from kagglesdk.datasets.types.dataset_types import DatasetSettings, \
SettingsLicense, UserRole, DatasetSettingsFile
SettingsLicense, DatasetCollaborator, DatasetSettingsFile
from kagglesdk.kernels.types.kernels_api_service import ApiListKernelsRequest, \
ApiListKernelFilesRequest, ApiSaveKernelRequest, ApiGetKernelRequest, \
ApiListKernelSessionOutputRequest, ApiGetKernelSessionStatusRequest
Expand Down
28 changes: 14 additions & 14 deletions kagglesdk/datasets/types/dataset_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DatasetInfo(KaggleObject):
is_private (bool)
keywords (str)
licenses (SettingsLicense)
collaborators (UserRole)
collaborators (DatasetCollaborator)
data (DatasetSettingsFile)
"""

Expand Down Expand Up @@ -220,18 +220,18 @@ def licenses(self, licenses: Optional[List[Optional['SettingsLicense']]]):
self._licenses = licenses

@property
def collaborators(self) -> Optional[List[Optional['UserRole']]]:
def collaborators(self) -> Optional[List[Optional['DatasetCollaborator']]]:
return self._collaborators

@collaborators.setter
def collaborators(self, collaborators: Optional[List[Optional['UserRole']]]):
def collaborators(self, collaborators: Optional[List[Optional['DatasetCollaborator']]]):
if collaborators is None:
del self.collaborators
return
if not isinstance(collaborators, list):
raise TypeError('collaborators must be of type list')
if not all([isinstance(t, UserRole) for t in collaborators]):
raise TypeError('collaborators must contain only items of type UserRole')
if not all([isinstance(t, DatasetCollaborator) for t in collaborators]):
raise TypeError('collaborators must contain only items of type DatasetCollaborator')
self._collaborators = collaborators

@property
Expand Down Expand Up @@ -259,7 +259,7 @@ class DatasetSettings(KaggleObject):
is_private (bool)
keywords (str)
licenses (SettingsLicense)
collaborators (UserRole)
collaborators (DatasetCollaborator)
data (DatasetSettingsFile)
"""

Expand Down Expand Up @@ -357,18 +357,18 @@ def licenses(self, licenses: Optional[List[Optional['SettingsLicense']]]):
self._licenses = licenses

@property
def collaborators(self) -> Optional[List[Optional['UserRole']]]:
def collaborators(self) -> Optional[List[Optional['DatasetCollaborator']]]:
return self._collaborators

@collaborators.setter
def collaborators(self, collaborators: Optional[List[Optional['UserRole']]]):
def collaborators(self, collaborators: Optional[List[Optional['DatasetCollaborator']]]):
if collaborators is None:
del self.collaborators
return
if not isinstance(collaborators, list):
raise TypeError('collaborators must be of type list')
if not all([isinstance(t, UserRole) for t in collaborators]):
raise TypeError('collaborators must contain only items of type UserRole')
if not all([isinstance(t, DatasetCollaborator) for t in collaborators]):
raise TypeError('collaborators must contain only items of type DatasetCollaborator')
self._collaborators = collaborators

@property
Expand Down Expand Up @@ -536,7 +536,7 @@ def name(self, name: str):
self._name = name


class UserRole(KaggleObject):
class DatasetCollaborator(KaggleObject):
r"""
Attributes:
username (str)
Expand Down Expand Up @@ -589,7 +589,7 @@ def role(self, role: 'CollaboratorType'):
FieldMetadata("isPrivate", "is_private", "_is_private", bool, False, PredefinedSerializer()),
FieldMetadata("keywords", "keywords", "_keywords", str, [], ListSerializer(PredefinedSerializer())),
FieldMetadata("licenses", "licenses", "_licenses", SettingsLicense, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("collaborators", "collaborators", "_collaborators", UserRole, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("collaborators", "collaborators", "_collaborators", DatasetCollaborator, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("data", "data", "_data", DatasetSettingsFile, [], ListSerializer(KaggleObjectSerializer())),
]

Expand All @@ -600,7 +600,7 @@ def role(self, role: 'CollaboratorType'):
FieldMetadata("isPrivate", "is_private", "_is_private", bool, False, PredefinedSerializer()),
FieldMetadata("keywords", "keywords", "_keywords", str, [], ListSerializer(PredefinedSerializer())),
FieldMetadata("licenses", "licenses", "_licenses", SettingsLicense, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("collaborators", "collaborators", "_collaborators", UserRole, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("collaborators", "collaborators", "_collaborators", DatasetCollaborator, [], ListSerializer(KaggleObjectSerializer())),
FieldMetadata("data", "data", "_data", DatasetSettingsFile, [], ListSerializer(KaggleObjectSerializer())),
]

Expand All @@ -621,7 +621,7 @@ def role(self, role: 'CollaboratorType'):
FieldMetadata("name", "name", "_name", str, None, PredefinedSerializer(), optional=True),
]

UserRole._fields = [
DatasetCollaborator._fields = [
FieldMetadata("username", "username", "_username", str, "", PredefinedSerializer()),
FieldMetadata("role", "role", "_role", CollaboratorType, CollaboratorType.COLLABORATOR_TYPE_UNSPECIFIED, EnumSerializer()),
]
Expand Down
2 changes: 1 addition & 1 deletion src/kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from kagglesdk.datasets.types.dataset_enums import DatasetSelectionGroup, \
DatasetSortBy, DatasetFileTypeGroup, DatasetLicenseGroup
from kagglesdk.datasets.types.dataset_types import DatasetSettings, \
SettingsLicense, UserRole, DatasetSettingsFile
SettingsLicense, DatasetCollaborator, DatasetSettingsFile
from kagglesdk.kernels.types.kernels_api_service import ApiListKernelsRequest, \
ApiListKernelFilesRequest, ApiSaveKernelRequest, ApiGetKernelRequest, \
ApiListKernelSessionOutputRequest, ApiGetKernelSessionStatusRequest
Expand Down

0 comments on commit 68c89f4

Please sign in to comment.