From 4a86f6d35fbaac60d46e68f384161e08a48bc4c7 Mon Sep 17 00:00:00 2001 From: Chi Lung Cheng <chi.lung.cheng@cern.ch> Date: Fri, 25 Nov 2022 15:39:37 +0100 Subject: [PATCH 1/3] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 73ee6e8f..b639af27 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ deprecated backup/ dev/ quickstats/macros/CMSSWCore/ +quickstats/resources/workspace_extensions.json -- GitLab From e62a4bbbe8cba92f8227527255007f067b7e83e2 Mon Sep 17 00:00:00 2001 From: Chi Lung Cheng <chi.lung.cheng@cern.ch> Date: Fri, 25 Nov 2022 15:41:06 +0100 Subject: [PATCH 2/3] change default file for checking workspace extension --- quickstats/_version.py | 2 +- quickstats/core/methods.py | 20 +++++++++++-------- .../default_workspace_extensions.json | 8 ++++++++ .../resources/workspace_extensions.json | 3 ++- setup.py | 1 + 5 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 quickstats/resources/default_workspace_extensions.json diff --git a/quickstats/_version.py b/quickstats/_version.py index 8ac19a84..4ac5910f 100644 --- a/quickstats/_version.py +++ b/quickstats/_version.py @@ -1 +1 @@ -__version__ = "0.6.5.7" +__version__ = "0.6.5.9" diff --git a/quickstats/core/methods.py b/quickstats/core/methods.py index cd9d5483..6b30e678 100644 --- a/quickstats/core/methods.py +++ b/quickstats/core/methods.py @@ -58,10 +58,7 @@ def get_root_version(): return root_version def get_workspace_extensions(): - resource_path = quickstats.resource_path - extension_config_file = os.path.join(resource_path, "workspace_extensions.json") - with open(extension_config_file, "r") as file: - extension_config = json.load(file) + extension_config = get_workspace_extension_config() extensions = extension_config['required'] if not extension_config['strict']: # deprecated extension @@ -69,6 +66,15 @@ def get_workspace_extensions(): extensions.remove('FlexibleInterpVarMkII') return extensions +def get_workspace_extension_config(): + resource_path = quickstats.resource_path + extension_config_file = os.path.join(resource_path, "workspace_extensions.json") + if not os.path.exists(extension_config_file): + extension_config_file = os.path.join(resource_path, "default_workspace_extensions.json") + with open(extension_config_file, "r") as file: + extension_config = json.load(file) + return extension_config + def add_macro(path:str, name:Optional[str]=None, copy_files:bool=True, workspace_extension:bool=True): if not os.path.isdir(path): raise ValueError("macro path must be a directory") @@ -94,8 +100,7 @@ def add_macro(path:str, name:Optional[str]=None, copy_files:bool=True, workspace if workspace_extension: resource_path = quickstats.resource_path extension_config_file = os.path.join(resource_path, "workspace_extensions.json") - with open(extension_config_file, "r") as file: - extension_config = json.load(file) + extension_config = get_workspace_extension_config() if name not in extension_config['required']: extension_config['required'].append(name) with open(extension_config_file, "w") as file: @@ -105,8 +110,7 @@ def add_macro(path:str, name:Optional[str]=None, copy_files:bool=True, workspace def remove_macro(name:str, remove_files:bool=True): resource_path = quickstats.resource_path extension_config_file = os.path.join(resource_path, "workspace_extensions.json") - with open(extension_config_file, "r") as file: - extension_config = json.load(file) + extension_config = get_workspace_extension_config() if (name not in extension_config): quickstats.__PRINT__.info(f'WARNING: Extension "{name}" not found in the workspace extension list. Skipped.') else: diff --git a/quickstats/resources/default_workspace_extensions.json b/quickstats/resources/default_workspace_extensions.json new file mode 100644 index 00000000..47428c07 --- /dev/null +++ b/quickstats/resources/default_workspace_extensions.json @@ -0,0 +1,8 @@ +{ + "required": [ + "RooTwoSidedCBShape", + "FlexibleInterpVarMkII", + "ResponseFunction" + ], + "strict": false +} \ No newline at end of file diff --git a/quickstats/resources/workspace_extensions.json b/quickstats/resources/workspace_extensions.json index 47428c07..0db047da 100644 --- a/quickstats/resources/workspace_extensions.json +++ b/quickstats/resources/workspace_extensions.json @@ -2,7 +2,8 @@ "required": [ "RooTwoSidedCBShape", "FlexibleInterpVarMkII", - "ResponseFunction" + "ResponseFunction", + "CMSSWCore" ], "strict": false } \ No newline at end of file diff --git a/setup.py b/setup.py index 11cc5ce4..50fde5d0 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ setup( long_description_content_type="text/markdown", packages=setuptools.find_packages(), package_data={'quickstats':['macros/*/*.cxx', 'macros/*/*.h', 'stylesheets/*', 'resources/*']}, + exclude_package_data={'quickstats':['macros/CMSSWCore/*', 'resources/workspace_extensions.json']}, classifiers=[ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", -- GitLab From 3bd30e409a32358cbb7738f8869af4e5206cd1f7 Mon Sep 17 00:00:00 2001 From: Chi Lung Cheng <chi.lung.cheng@cern.ch> Date: Fri, 25 Nov 2022 15:51:05 +0100 Subject: [PATCH 3/3] remove user defined workspace extension config --- quickstats/resources/workspace_extensions.json | 9 --------- setup.sh | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 quickstats/resources/workspace_extensions.json diff --git a/quickstats/resources/workspace_extensions.json b/quickstats/resources/workspace_extensions.json deleted file mode 100644 index 0db047da..00000000 --- a/quickstats/resources/workspace_extensions.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "required": [ - "RooTwoSidedCBShape", - "FlexibleInterpVarMkII", - "ResponseFunction", - "CMSSWCore" - ], - "strict": false -} \ No newline at end of file diff --git a/setup.sh b/setup.sh index 699acabd..1469d468 100644 --- a/setup.sh +++ b/setup.sh @@ -30,11 +30,11 @@ then export PYTHONPATH=${DIR}:${PYTHONPATH} elif [[ "$EnvironmentName" = "dev" ]]; then - export PATH=/afs/cern.ch/work/c/chlcheng/local/miniconda/envs/ml-base/bin:$PATH + export PATH=/afs/cern.ch/work/c/chlcheng/local/miniconda/envs/root-latest/bin:$PATH export PATH=${DIR}/bin:${PATH} export PYTHONPATH=${DIR}:${PYTHONPATH} elif [[ "$EnvironmentName" = "conda" ]]; then echo Entering default conda environment - export PATH=/afs/cern.ch/work/c/chlcheng/local/miniconda/envs/ml-base/bin:$PATH + export PATH=/afs/cern.ch/work/c/chlcheng/local/miniconda/envs/root-latest/bin:$PATH fi \ No newline at end of file -- GitLab