diff --git a/backend/dataall/modules/datasets/services/dataset_service.py b/backend/dataall/modules/datasets/services/dataset_service.py index 869679f90..9f8207f5d 100644 --- a/backend/dataall/modules/datasets/services/dataset_service.py +++ b/backend/dataall/modules/datasets/services/dataset_service.py @@ -113,6 +113,7 @@ def create_dataset(uri, admin_group, data: dict): session=session, env=environment, dataset=dataset, + data=data ) DatasetBucketRepository.create_dataset_bucket(session, dataset, data) diff --git a/backend/dataall/modules/datasets_base/db/dataset_repositories.py b/backend/dataall/modules/datasets_base/db/dataset_repositories.py index ad4b626ab..ee54217c5 100644 --- a/backend/dataall/modules/datasets_base/db/dataset_repositories.py +++ b/backend/dataall/modules/datasets_base/db/dataset_repositories.py @@ -33,7 +33,7 @@ def build_dataset(cls, username: str, env: Environment, data: dict) -> Dataset: AwsAccountId=env.AwsAccountId, SamlAdminGroupName=data['SamlAdminGroupName'], region=env.region, - S3BucketName='undefined', + S3BucketName=data.get('bucketName', 'undefined'), GlueDatabaseName='undefined', IAMDatasetAdminRoleArn='undefined', IAMDatasetAdminUserArn='undefined', @@ -52,7 +52,7 @@ def build_dataset(cls, username: str, env: Environment, data: dict) -> Dataset: else data['SamlAdminGroupName'], autoApprovalEnabled=data.get('autoApprovalEnabled', False), ) - cls._set_dataset_aws_resources(dataset, data, env) + cls._set_import_data(dataset, data) return dataset @@ -75,15 +75,16 @@ def count_resources(session, environment, group_uri) -> int: .count() ) - @staticmethod - def create_dataset(session, env: Environment, dataset: Dataset): + @classmethod + def create_dataset(cls, session, env: Environment, dataset: Dataset, data: dict): organization = OrganizationRepository.get_organization_by_uri( session, env.organizationUri ) - session.add(dataset) session.commit() + cls._set_dataset_aws_resources(dataset, data, env) + activity = Activity( action='dataset:create', label='dataset:create', @@ -114,7 +115,8 @@ def _set_dataset_aws_resources(dataset: Dataset, data, environment): ).build_compliant_name() dataset.GlueDatabaseName = data.get('glueDatabaseName') or glue_db_name - dataset.KmsAlias = bucket_name + if not dataset.imported: + dataset.KmsAlias = bucket_name iam_role_name = NamingConventionService( target_uri=dataset.datasetUri,