From ce3ae4b3158cb8e175f05057a4adeb578ffbe5a0 Mon Sep 17 00:00:00 2001 From: Vadym Moshynskyi Date: Fri, 14 Jul 2023 12:05:46 +0200 Subject: [PATCH 1/2] PILOT-3306: Remove use_config command functionality --- app/commands/entry_point.py | 15 +--------- app/commands/use_config.py | 29 ------------------- app/resources/custom_error.py | 5 ---- app/services/output_manager/error_handler.py | 2 -- app/services/output_manager/help_page.py | 10 ------- app/services/user_authentication/decorator.py | 10 ------- .../user_authentication/user_set_config.py | 27 ----------------- 7 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 app/commands/use_config.py delete mode 100644 app/services/user_authentication/user_set_config.py diff --git a/app/commands/entry_point.py b/app/commands/entry_point.py index e9ed194c..757e42b7 100644 --- a/app/commands/entry_point.py +++ b/app/commands/entry_point.py @@ -6,7 +6,6 @@ import click -from app.services.user_authentication.decorator import require_config from app.services.user_authentication.decorator import require_login_session from .container_registry import create_project @@ -26,7 +25,6 @@ # Import custom commands from .project import project_list_all -from .use_config import set_env from .user import login from .user import logout @@ -34,7 +32,7 @@ def command_groups(): - commands = ['file', 'user', 'use_config', 'project', 'dataset'] + commands = ['file', 'user', 'project', 'dataset'] if container_registry_enabled: commands.append('container_registry') return commands @@ -46,37 +44,28 @@ def entry_point(): @entry_point.group(name='project') -@require_config @require_login_session def project_group(): pass @entry_point.group(name='dataset') -@require_config @require_login_session def dataset_group(): pass @entry_point.group(name='file') -@require_config @require_login_session def file_group(): pass @entry_point.group(name='user') -@require_config def user_group(): pass -@entry_point.group(name='use_config') -def config_group(): - pass - - file_group.add_command(file_put) file_group.add_command(file_check_manifest) file_group.add_command(file_export_manifest) @@ -89,13 +78,11 @@ def config_group(): dataset_group.add_command(dataset_list) dataset_group.add_command(dataset_show_detail) dataset_group.add_command(dataset_download) -config_group.add_command(set_env) # Custom commands if container_registry_enabled: @entry_point.group(name='container_registry') - @require_config def cr_group(): pass diff --git a/app/commands/use_config.py b/app/commands/use_config.py deleted file mode 100644 index cabe07fd..00000000 --- a/app/commands/use_config.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2022-2023 Indoc Research -# -# Contact Indoc Research for any questions regarding the use of this source code. - -import click - -import app.services.output_manager.help_page as config_help -from app.services.user_authentication.user_set_config import set_config -from app.utils.aggregated import doc - - -@click.command() -def cli(): - """Config Actions.""" - pass - - -@click.command() -@click.argument('path', type=click.Path(exists=True), nargs=1) -@click.option( - '-o', - '--output', - type=click.Path(), - default='.', - help=config_help.config_help_page(config_help.ConfigHELP.CONFIG_DESTINATION), -) -@doc(config_help.config_help_page(config_help.ConfigHELP.SET_CONFIG)) -def set_env(path, output): - set_config(path, output) diff --git a/app/resources/custom_error.py b/app/resources/custom_error.py index afb6b512..5bdd2dc0 100644 --- a/app/resources/custom_error.py +++ b/app/resources/custom_error.py @@ -112,11 +112,6 @@ class Error: 'sensitive identifiers, please cancel this transfer and upload the data to the Green Room to perform ' 'these actions.' ), - 'CONFIG_NOT_FOUND': 'This cli is not setup properly, please download config file and config again.', - 'CONFIG_EXIST': ( - 'This cli has been configured already.' - 'If you want to re-config this cli please remove previous file first' - ), 'CONFIG_INVALID_PERMISSIONS': 'Cannot proceed with current config permissions.\n%s', 'CONTAINER_REGISTRY_NO_URL': ( 'Container registry has not yet been configured. Related commands cannot be used at this time.' diff --git a/app/services/output_manager/error_handler.py b/app/services/output_manager/error_handler.py index 452b812e..32e66079 100644 --- a/app/services/output_manager/error_handler.py +++ b/app/services/output_manager/error_handler.py @@ -77,8 +77,6 @@ class ECustomizedError(enum.Enum): USER_NOT_FOUND = 'USER_NOT_FOUND' CONTAINER_REGISTRY_OTHER = 'CONTAINER_REGISTRY_OTHER' CONTAINER_REGISTRY_NO_URL = 'CONTAINER_REGISTRY_NO_URL' - CONFIG_NOT_FOUND = 'CONFIG_NOT_FOUND' - CONFIG_EXIST = 'CONFIG_EXIST' CONFIG_INVALID_PERMISSIONS = 'CONFIG_INVALID_PERMISSIONS' diff --git a/app/services/output_manager/help_page.py b/app/services/output_manager/help_page.py index 033c16ce..17793d71 100644 --- a/app/services/output_manager/help_page.py +++ b/app/services/output_manager/help_page.py @@ -37,16 +37,6 @@ def project_help_page(ProjectHELP: ProjectHELP): return helps.get(ProjectHELP.name) -class ConfigHELP(enum.Enum): - SET_CONFIG = 'SET_CONFIG' - CONFIG_DESTINATION = 'CONFIG_DESTINATION' - - -def config_help_page(ConfigHELP: ConfigHELP): - helps = help_msg.get('config', 'default config help') - return helps.get(ConfigHELP.name) - - class UserHELP(enum.Enum): USER_LOGIN = 'USER_LOGIN' USER_LOGOUT = 'USER_LOGOUT' diff --git a/app/services/user_authentication/decorator.py b/app/services/user_authentication/decorator.py index e3508df5..1b485e0a 100644 --- a/app/services/user_authentication/decorator.py +++ b/app/services/user_authentication/decorator.py @@ -11,7 +11,6 @@ from .token_manager import SrvTokenManager from .user_login_logout import check_is_active from .user_login_logout import check_is_login -from .user_set_config import check_config def require_valid_token(azp=AppConfig.Env.keycloak_device_client_id): @@ -53,12 +52,3 @@ def decorated(*args, **kwargs): return func(*args, **kwargs) return decorated - - -def require_config(func): - @wraps(func) - def decorated(*args, **kwargs): - check_config() - return func(*args, **kwargs) - - return decorated diff --git a/app/services/user_authentication/user_set_config.py b/app/services/user_authentication/user_set_config.py deleted file mode 100644 index faf8def2..00000000 --- a/app/services/user_authentication/user_set_config.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2022-2023 Indoc Research -# -# Contact Indoc Research for any questions regarding the use of this source code. - -import os -import shutil - -from app.configs import app_config -from app.services.logger_services import log_functions as logger -from app.services.output_manager.error_handler import ECustomizedError -from app.services.output_manager.error_handler import SrvErrorHandler - - -def check_config(): - connections = app_config.AppConfig.Connections.__dict__ - for k, v in connections.items(): - if k.startswith('url') and not v: - SrvErrorHandler.customized_handle(ECustomizedError.CONFIG_NOT_FOUND, True) - - -def set_config(target_path, destination): - config_path = os.path.join(destination, '.env') - if os.path.isfile(config_path): - SrvErrorHandler.customized_handle(ECustomizedError.CONFIG_EXIST, True) - else: - shutil.copy(target_path, destination) - logger.succeed('config file set') From c5b8b387c1950a7bd6ddad1d15b8db77438dd638 Mon Sep 17 00:00:00 2001 From: Vadym Moshynskyi Date: Fri, 14 Jul 2023 12:41:51 +0200 Subject: [PATCH 2/2] PILOT-3306: Remove lineage leftovers --- app/configs/app_config.py | 1 - app/resources/custom_error.py | 3 +-- app/services/output_manager/error_handler.py | 1 - env.py | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/configs/app_config.py b/app/configs/app_config.py index 52646fe4..f7a388a2 100644 --- a/app/configs/app_config.py +++ b/app/configs/app_config.py @@ -45,7 +45,6 @@ class Connections: url_upload_greenroom = ConfigClass.url_upload_greenroom url_upload_core = ConfigClass.url_upload_core url_status = ConfigClass.url_status - url_lineage = ConfigClass.url_lineage url_download_greenroom = ConfigClass.url_download_greenroom url_download_core = ConfigClass.url_download_core url_v2_download_pre = ConfigClass.url_v2_download_pre diff --git a/app/resources/custom_error.py b/app/resources/custom_error.py index 5bdd2dc0..10d594d4 100644 --- a/app/resources/custom_error.py +++ b/app/resources/custom_error.py @@ -36,7 +36,6 @@ class Error: 'INVALID_ATTRIBUTE': "Invalid attribute '%s'. Please verify and try again.", 'INVALID_UPLOAD_REQUEST': 'Invalid upload request: %s', 'INVALID_SOURCE_FILE': 'File does not exist or source file provided is invalid: %s', - 'INVALID_LINEAGE': 'Create lineage failed: %s', 'INVALID_PIPELINENAME': ( 'Invalid pipeline name. Pipeline names must be between 1 and 20 characters long and ' 'may only contain lowercase letters, numbers, and/or special characters of -_, .' @@ -66,7 +65,7 @@ class Error: 'It means the resumable file is not the same with previous one.\n' 'Please to double check the file content.' ), - 'UNSUPPORT_TAG_MANIFEST': 'Tagging, lineage and manifest attaching are not supported for folder type.', + 'UNSUPPORT_TAG_MANIFEST': 'Tagging and manifest attaching are not supported for folder type.', 'INVALID_INPUT': 'Invalid input. Please try again.', 'UNSUPPORTED_PROJECT': 'This function is not supported in the given Project %s', 'CREATE_FOLDER_IF_NOT_EXIST': 'Target folder does not exist. Would you like to create a new folder?', diff --git a/app/services/output_manager/error_handler.py b/app/services/output_manager/error_handler.py index 32e66079..e79ee130 100644 --- a/app/services/output_manager/error_handler.py +++ b/app/services/output_manager/error_handler.py @@ -29,7 +29,6 @@ class ECustomizedError(enum.Enum): MISSING_REQUIRED_ATTRIBUTE = 'MISSING_REQUIRED_ATTRIBUTE' INVALID_UPLOAD_REQUEST = 'INVALID_UPLOAD_REQUEST' INVALID_SOURCE_FILE = 'INVALID_SOURCE_FILE' - INVALID_LINEAGE = 'INVALID_LINEAGE' INVALID_PIPELINENAME = 'INVALID_PIPELINENAME' INVALID_PATHS = 'INVALID_PATHS' INVALID_RESUMABLE = 'INVALID_RESUMABLE' diff --git a/env.py b/env.py index 90f67c74..551c322d 100644 --- a/env.py +++ b/env.py @@ -43,7 +43,6 @@ def modify_values(self, settings): settings.url_dataset_v2download = settings.base_url + 'portal/download/core/v2/dataset' settings.url_dataset = settings.base_url + 'portal/v1/dataset' settings.url_validation = settings.base_url + 'v1/files/validation' - settings.url_lineage = settings.url_bff + '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/v1/lineage' return settings