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

Enum refactoring #978

Merged
merged 9 commits into from
Jan 26, 2024
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
4 changes: 2 additions & 2 deletions backend/dataall/core/environment/db/environment_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.orm import query_expression
from dataall.base.db import Resource, Base, utils

from dataall.core.environment.api.enums import EnvironmentPermission
from dataall.core.environment.api.enums import EnvironmentPermission, EnvironmentType


class Environment(Resource, Base):
Expand All @@ -18,7 +18,7 @@ class Environment(Resource, Base):
resourcePrefix = Column(String, nullable=False, default='dataall')

validated = Column(Boolean, default=False)
environmentType = Column(String, nullable=False, default='Data')
environmentType = Column(String, nullable=False, default=EnvironmentType.Data.value)
isOrganizationDefaultEnvironment = Column(Boolean, default=False)
EnvironmentDefaultIAMRoleName = Column(String, nullable=False)
EnvironmentDefaultIAMRoleImported = Column(Boolean, default=False)
Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/core/organizations/api/input_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataall.base.api.constants import GraphQLEnumMapper, SortDirection
from dataall.base.api import gql
from dataall.core.organizations.api.enums import OrganisationUserRole
from dataall.core.organizations.services.organizations_enums import OrganisationUserRole

NewOrganizationInput = gql.InputType(
name='NewOrganizationInput',
Expand Down
9 changes: 0 additions & 9 deletions backend/dataall/core/organizations/db/organization_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
from enum import Enum

from sqlalchemy import Column, String, DateTime
from sqlalchemy.orm import query_expression
Expand All @@ -8,14 +7,6 @@
from dataall.base.db import Resource, utils


class OrganisationUserRole(Enum):
Owner = '999'
Admin = '900'
Member = '100'
NotMember = '000'
Invited = '800'


class Organization(Resource, Base):
__tablename__ = 'organization'
organizationUri = Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from dataall.core.activity.db.activity_models import Activity
from dataall.core.environment.db.environment_repositories import EnvironmentRepository
from dataall.core.organizations.db.organization_repositories import OrganizationRepository
from dataall.core.organizations.db.organization_models import OrganisationUserRole, OrganizationGroup
from dataall.core.organizations.services.organizations_enums import OrganisationUserRole
from dataall.core.organizations.db.organization_models import OrganizationGroup
from dataall.core.organizations.db import organization_models as models
from dataall.core.permissions import permissions
from dataall.core.permissions.permission_checker import has_tenant_permission, has_resource_permission
Expand Down Expand Up @@ -137,7 +138,7 @@ def resolve_user_role(organization):
else:
with context.db_engine.scoped_session() as session:
if OrganizationRepository.find_organization_membership(
session=session, uri=organization.organizationUri, groups=context.groups
session=session, uri=organization.organizationUri, groups=context.groups
):
return OrganisationUserRole.Invited.value
return OrganisationUserRole.NoPermission.value
Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/modules/dataset_sharing/api/input_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataall.base.api.constants import *
from dataall.modules.dataset_sharing.api.enums import ShareableType, ShareSortField
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareableType, ShareSortField


NewShareObjectInput = gql.InputType(
Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/modules/dataset_sharing/api/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataall.core.environment.services.environment_service import EnvironmentService
from dataall.core.organizations.db.organization_repositories import OrganizationRepository
from dataall.base.db.exceptions import RequiredParameter
from dataall.modules.dataset_sharing.api.enums import ShareObjectPermission
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectPermission
from dataall.modules.dataset_sharing.db.share_object_models import ShareObjectItem, ShareObject
from dataall.modules.dataset_sharing.services.share_item_service import ShareItemService
from dataall.modules.dataset_sharing.services.share_object_service import ShareObjectService
Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/modules/dataset_sharing/api/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataall.base.api import gql
from dataall.modules.dataset_sharing.api.enums import ShareableType, PrincipalType
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareableType, PrincipalType
from dataall.modules.dataset_sharing.api.resolvers import union_resolver, resolve_shared_item, resolve_dataset, \
resolve_consumption_data, resolve_existing_shared_items, resolve_share_object_statistics, resolve_principal, \
resolve_group, list_shareable_objects, resolve_user_role
Expand Down
71 changes: 0 additions & 71 deletions backend/dataall/modules/dataset_sharing/db/enums.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.orm import query_expression

from dataall.base.db import Base, utils
from dataall.modules.dataset_sharing.db.enums import ShareObjectStatus, ShareItemStatus
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectStatus, ShareItemStatus


def in_one_month():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dataall.core.environment.services.environment_resource_manager import EnvironmentResource
from dataall.core.organizations.db.organization_models import Organization
from dataall.base.db import exceptions, paginate
from dataall.modules.dataset_sharing.db.enums import ShareObjectActions, ShareObjectStatus, ShareItemActions, \
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectActions, ShareObjectStatus, ShareItemActions, \
ShareItemStatus, ShareableType, PrincipalType
from dataall.modules.dataset_sharing.db.share_object_models import ShareObjectItem, ShareObject
from dataall.modules.datasets_base.db.dataset_repositories import DatasetRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging

from dataall.base.db import Engine
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectSM, ShareObjectRepository, \
ShareItemSM
from dataall.modules.dataset_sharing.services.share_processors.lf_process_cross_account_share import \
ProcessLFCrossAccountShare
from dataall.modules.dataset_sharing.services.share_processors.lf_process_same_account_share import \
Expand All @@ -8,11 +11,7 @@
ProcessS3AccessPointShare
from dataall.modules.dataset_sharing.services.share_processors.s3_bucket_process_share import ProcessS3BucketShare

from dataall.base.db import Engine
from dataall.modules.dataset_sharing.db.enums import (ShareObjectActions, ShareItemStatus, ShareableType,
ShareItemActions)
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectSM, ShareObjectRepository, \
ShareItemSM
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import (ShareObjectActions, ShareItemStatus, ShareableType)

log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dataall.core.tasks.db.task_models import Task
from dataall.base.db import utils
from dataall.base.db.exceptions import ObjectNotFound, UnauthorizedOperation
from dataall.modules.dataset_sharing.db.enums import ShareObjectActions, ShareableType, ShareItemStatus, \
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectActions, ShareableType, ShareItemStatus, \
ShareItemActions
from dataall.modules.dataset_sharing.db.share_object_models import ShareObjectItem
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectRepository, ShareObjectSM, ShareItemSM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
from dataall.modules.datasets_base.db.dataset_models import Dataset
from dataall.base.context import get_context
from dataall.modules.dataset_sharing.db.enums import ShareObjectStatus
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectStatus
from dataall.modules.notifications.db.notification_repositories import NotificationRepository

log = logging.getLogger(__name__)
Expand All @@ -32,6 +32,7 @@ class ShareNotificationService:
- dataset.stewards
- share.owner (person that opened the request) OR share.groupUri (if group_notifications=true)
"""

def __init__(self, session, dataset: Dataset, share: ShareObject):
self.dataset = dataset
self.share = share
Expand Down Expand Up @@ -139,11 +140,11 @@ def _create_notification_task(self, subject, msg):
action='notification.service',
targetUri=self.share.shareUri,
payload={
'notificationType' : share_notification_config_type,
'notificationType': share_notification_config_type,
'subject': subject,
'message': msg,
'recipientGroupsList' : notification_recipient_groups_list,
'recipientEmailList' : notification_recipient_email_ids
'recipientGroupsList': notification_recipient_groups_list,
'recipientEmailList': notification_recipient_email_ids
},
)
self.session.add(notification_task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataall.base.db import utils
from dataall.base.aws.quicksight import QuicksightClient
from dataall.base.db.exceptions import UnauthorizedOperation
from dataall.modules.dataset_sharing.db.enums import ShareObjectActions, ShareableType, ShareItemStatus, \
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareObjectActions, ShareableType, ShareItemStatus, \
ShareObjectStatus, PrincipalType
from dataall.modules.dataset_sharing.db.share_object_models import ShareObjectItem, ShareObject
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectRepository, ShareObjectSM, ShareItemSM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from dataall.core.environment.db.environment_models import Environment, EnvironmentGroup
from dataall.modules.dataset_sharing.db.enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from ..share_managers import LFShareManager
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.services.share_managers import LFShareManager
from dataall.modules.dataset_sharing.aws.ram_client import RamClient
from dataall.modules.datasets_base.db.dataset_models import DatasetTable, Dataset
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

from dataall.core.environment.db.environment_models import Environment, EnvironmentGroup
from dataall.modules.dataset_sharing.db.enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectRepository, ShareItemSM
from ..share_managers import LFShareManager
from dataall.modules.dataset_sharing.services.share_managers import LFShareManager
from dataall.modules.datasets_base.db.dataset_models import DatasetTable, Dataset

log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataall.core.environment.db.environment_models import Environment, EnvironmentGroup
from dataall.modules.dataset_sharing.services.share_managers import S3AccessPointShareManager
from dataall.modules.datasets_base.db.dataset_models import DatasetStorageLocation, Dataset
from dataall.modules.dataset_sharing.db.enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectRepository, ShareItemSM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataall.core.environment.db.environment_models import Environment, EnvironmentGroup
from dataall.modules.dataset_sharing.services.share_managers import S3BucketShareManager
from dataall.modules.datasets_base.db.dataset_models import Dataset, DatasetBucket
from dataall.modules.dataset_sharing.db.enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.services.dataset_sharing_enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
from dataall.modules.dataset_sharing.db.share_object_repositories import ShareObjectRepository, ShareItemSM

Expand Down
5 changes: 2 additions & 3 deletions backend/dataall/modules/datasets/api/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
mutations,
queries,
resolvers,
types,
enums
types
)

__all__ = ['resolvers', 'types', 'input_types', 'queries', 'mutations', 'enums']
__all__ = ['resolvers', 'types', 'input_types', 'queries', 'mutations']
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataall.base.api import gql
from dataall.base.api.constants import SortDirection
from dataall.modules.datasets.api.dataset.enums import DatasetSortField
from dataall.modules.datasets_base.services.datasets_base_enums import DatasetSortField


NewDatasetInput = gql.InputType(
Expand Down
10 changes: 5 additions & 5 deletions backend/dataall/modules/datasets/api/dataset/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataall.base.db.exceptions import RequiredParameter, InvalidInput
from dataall.modules.dataset_sharing.db.share_object_models import ShareObject
from dataall.modules.datasets_base.db.dataset_models import Dataset
from dataall.modules.datasets.api.dataset.enums import DatasetRole
from dataall.modules.datasets_base.services.datasets_base_enums import DatasetRole
from dataall.modules.datasets.services.dataset_service import DatasetService

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -60,7 +60,7 @@ def resolve_user_role(context: Context, source: Dataset, **kwargs):

@is_feature_enabled('modules.datasets.features.file_uploads')
def get_file_upload_presigned_url(
context, source, datasetUri: str = None, input: dict = None
context, source, datasetUri: str = None, input: dict = None
):
return DatasetService.get_file_upload_presigned_url(uri=datasetUri, data=input)

Expand Down Expand Up @@ -162,7 +162,7 @@ def get_dataset_stack(context: Context, source: Dataset, **kwargs):


def delete_dataset(
context: Context, source, datasetUri: str = None, deleteFromAWS: bool = False
context: Context, source, datasetUri: str = None, deleteFromAWS: bool = False
):
return DatasetService.delete_dataset(uri=datasetUri, delete_from_aws=deleteFromAWS)

Expand All @@ -175,15 +175,15 @@ def get_dataset_glossary_terms(context: Context, source: Dataset, **kwargs):


def list_datasets_created_in_environment(
context: Context, source, environmentUri: str = None, filter: dict = None
context: Context, source, environmentUri: str = None, filter: dict = None
):
if not filter:
filter = {}
return DatasetService.list_datasets_created_in_environment(uri=environmentUri, data=filter)


def list_datasets_owned_by_env_group(
context, source, environmentUri: str = None, groupUri: str = None, filter: dict = None
context, source, environmentUri: str = None, groupUri: str = None, filter: dict = None
):
if not filter:
filter = {}
Expand Down
5 changes: 1 addition & 4 deletions backend/dataall/modules/datasets/api/dataset/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataall.base.api import gql
from dataall.modules.datasets.api.dataset.enums import DatasetRole
from dataall.modules.datasets_base.services.datasets_base_enums import DatasetRole
from dataall.modules.datasets.api.dataset.resolvers import (
get_dataset_environment,
get_dataset_organization,
Expand All @@ -15,7 +15,6 @@
)
from dataall.core.environment.api.enums import EnvironmentPermission


DatasetStatistics = gql.ObjectType(
name='DatasetStatistics',
fields=[
Expand Down Expand Up @@ -154,7 +153,6 @@
],
)


DatasetSearchResult = gql.ObjectType(
name='DatasetSearchResult',
fields=[
Expand All @@ -170,7 +168,6 @@
],
)


GlueCrawler = gql.ObjectType(
name='GlueCrawler',
fields=[
Expand Down
3 changes: 1 addition & 2 deletions backend/dataall/modules/datasets/api/table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
queries,
resolvers,
types,
enums,
)

__all__ = ['resolvers', 'types', 'input_types', 'queries', 'mutations', 'enums']
__all__ = ['resolvers', 'types', 'input_types', 'queries', 'mutations']
Loading
Loading