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 3 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
8 changes: 0 additions & 8 deletions backend/dataall/core/organizations/db/organization_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,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 @@ -5,7 +5,8 @@

from dataall.core.permissions import permissions
from dataall.base.db import exceptions, paginate
from dataall.core.organizations.db.organization_models import OrganizationGroup, OrganisationUserRole
from dataall.core.organizations.db.organization_models import OrganizationGroup
from dataall.core.organizations.api.enums import OrganisationUserRole
from dataall.core.organizations.db import organization_models as models
from dataall.core.environment.db.environment_models import Environment
from dataall.core.permissions.permission_checker import has_resource_permission, has_tenant_permission
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.common.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 Organization
from dataall.base.db.exceptions import RequiredParameter
from dataall.modules.dataset_sharing.api.enums import ShareObjectPermission
from dataall.modules.dataset_sharing.common.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.common.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
Empty file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

dlpzx marked this conversation as resolved.
Show resolved Hide resolved
from dataall.base.api.constants import GraphQLEnumMapper


dlpzx marked this conversation as resolved.
Show resolved Hide resolved
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 ..common.enums import ShareObjectStatus, ShareItemStatus
dlpzx marked this conversation as resolved.
Show resolved Hide resolved


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 ..common.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 ..common.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 ..common.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 ..common.enums import ShareObjectStatus
from dataall.modules.notifications.db.notification_repositories import NotificationRepository

log = logging.getLogger(__name__)
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 ..common.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,7 +1,7 @@
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.common.enums import ShareItemStatus, ShareObjectActions, ShareItemActions
from ..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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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.common.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
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.common.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.common.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.constants.enums import DatasetSortField


NewDatasetInput = gql.InputType(
Expand Down
12 changes: 6 additions & 6 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.constants.enums import DatasetRole
from dataall.modules.datasets.services.dataset_service import DatasetService

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -52,15 +52,15 @@ def resolve_user_role(context: Context, source: Dataset, **kwargs):
.first()
)
if share and (
share.owner == context.username or share.principalId in context.groups
share.owner == context.username or share.principalId in context.groups
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if these formatting changes are needed in this file

):
return DatasetRole.Shared.value
return DatasetRole.NoPermission.value


@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.constants.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 @@ -153,7 +152,6 @@
],
)


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


GlueCrawler = gql.ObjectType(
name='GlueCrawler',
fields=[
Expand Down
6 changes: 0 additions & 6 deletions backend/dataall/modules/datasets/api/table/enums.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from dataall.base.api.constants import GraphQLEnumMapper


class DatasetSortField(GraphQLEnumMapper):
created = 'created'
updated = 'updated'
label = 'label'


class DatasetTablePreviewStatus(GraphQLEnumMapper):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move this enum to datasets_base/constants/enums.py and get rid of this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enum is only used in dataall/modules/datasets/api/table/types.py:100 for the class DatasetTablePreviewResult that as far as I see it is not used. Maybe we can delete both the Enum and the gqlObjectType

QUEUED = 'QUEUED'
RUNNING = 'RUNNING'
Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/modules/datasets/api/table/input_types.py
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.table.enums import DatasetSortField
from dataall.modules.datasets_base.constants.enums import DatasetSortField


ModifyDatasetTableInput = gql.InputType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dataall.modules.datasets.services.dataset_permissions import UPDATE_DATASET_TABLE
from dataall.modules.datasets_base.db.dataset_models import DatasetTable, DatasetTableColumn
from dataall.modules.datasets_base.db.dataset_repositories import DatasetRepository
from dataall.modules.datasets_base.db.enums import ConfidentialityClassification
from dataall.modules.datasets_base.constants.enums import ConfidentialityClassification
from dataall.modules.datasets_base.services.permissions import PREVIEW_DATASET_TABLE


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataall.modules.datasets.db.dataset_table_repositories import DatasetTableRepository
from dataall.modules.datasets.services.dataset_permissions import PROFILE_DATASET_TABLE, GET_DATASET
from dataall.modules.datasets_base.db.dataset_repositories import DatasetRepository
from dataall.modules.datasets_base.db.enums import ConfidentialityClassification
from dataall.modules.datasets_base.constants.enums import ConfidentialityClassification
from dataall.modules.datasets_base.db.dataset_models import DatasetProfilingRun, DatasetTable
from dataall.modules.datasets_base.services.permissions import GET_DATASET_TABLE, PREVIEW_DATASET_TABLE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
DELETE_DATASET, MANAGE_DATASETS, UPDATE_DATASET, LIST_ENVIRONMENT_DATASETS, \
CREATE_DATASET, DATASET_ALL, DATASET_READ, IMPORT_DATASET
from dataall.modules.datasets_base.db.dataset_repositories import DatasetRepository
from dataall.modules.datasets_base.db.enums import DatasetRole
from dataall.modules.datasets_base.constants.enums import DatasetRole
from dataall.modules.datasets_base.db.dataset_models import Dataset, DatasetTable
from dataall.modules.datasets_base.services.permissions import DATASET_TABLE_READ

Expand Down
Loading
Loading