diff --git a/.gitignore b/.gitignore index 49faaab2cc761d158180af4f4cf04148b446a3c7..1f775968a0a20a73c028b0c6d451948d4f181f5d 100644 --- a/.gitignore +++ b/.gitignore @@ -145,12 +145,16 @@ higgs_dna/samples/*.json ### The following ingredients can be pulled with scripts/pull_files.py and are therefore not added to the index +## golden JSON +higgs_dna/metaconditions/CAF/ + ## JSONs for systematics # Weight-based Egamma objects higgs_dna/systematics/JSONs/TriggerSF/ higgs_dna/systematics/JSONs/Preselection/ higgs_dna/systematics/JSONs/ElectronVetoSF/ higgs_dna/systematics/JSONs/SF_photon_ID/ +higgs_dna/systematics/JSONs/LooseMvaSF/ # Weight-based jets higgs_dna/systematics/JSONs/cTagSF/ # Weight-based event level diff --git a/environment.yml b/environment.yml index 681b16509a77425db4fe1433159fcd465ff63a16..dd8a86cb72a7f2165f6d80487d153ee1f3f6f2c1 100644 --- a/environment.yml +++ b/environment.yml @@ -31,5 +31,6 @@ dependencies: - pandoc - pytorch - torchvision + - requests - pip: - zuko==1.0.1 diff --git a/higgs_dna/utils/runner_utils.py b/higgs_dna/utils/runner_utils.py index 6eacc72e38ebff9e8e8a7f9e3febf54f5aae8906..a6b487f145bfb61f21bc72498268550d87da2780 100644 --- a/higgs_dna/utils/runner_utils.py +++ b/higgs_dna/utils/runner_utils.py @@ -219,7 +219,7 @@ def get_main_parser(): "--fiducialCuts", default="classical", choices=["classical", "geometric", "none"], - help="Apply fiducial cuts at detector level according to standard CMS approach (classical with 1/3 and 1/4 thresholds for scaled pT of lead and sublead), geometric cuts (proposed in 2106.08329), or none at all. Fiducial selection at particle level is handled with taggers.", + help="Apply fiducial cuts at detector level according to standard CMS approach (classical with 1/3 and 1/4 thresholds for scaled pT of lead and sublead), geometric cuts (proposed in 2106.08329), or none at all. Fiducial flags for particle level are handled with utily functions and are unrelated to this argument.", ) parser.add_argument( "--doDeco", diff --git a/scripts/pull_files.py b/scripts/pull_files.py index 6e57193581cb75e149e9e396aa5cfee9c0fe00f1..cd6921645a311812761cfcffe381d6d3d3fec9c1 100644 --- a/scripts/pull_files.py +++ b/scripts/pull_files.py @@ -2,6 +2,7 @@ import argparse import os from higgs_dna.utils.logger_utils import setup_logger +import requests import urllib.request import pathlib import shutil @@ -83,6 +84,13 @@ def fetch_file(target_name, logger, from_to_dict, type="url"): try: with urllib.request.urlopen(from_to_dict[ikey]["from"]) as f: json_object = f.read().decode("utf-8") + except: + logger.info("INFO: urllib did not work, falling back to requests to fetch file from URL...") + pass + try: + response = requests.get(from_to_dict[ikey]["from"], verify=True) + response.raise_for_status() # Raise an exception for HTTP errors + json_object = response.text # create the folder p = pathlib.Path(from_to_dict[ikey]["to"]) p = pathlib.Path(*p.parts[:-1]) # remove file name diff --git a/setup.cfg b/setup.cfg index 3978d693958f097471007569e74dc6515f0aa820..10ab701169bd54a53f0875f77764c9cc27f6d362 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,7 @@ install_requires = dask-jobqueue correctionlib torch + requests zuko python_requires = >=3.6 include_package_data = True diff --git a/tests/test_parquet_scripts.py b/tests/test_parquet_scripts.py index d1d5ea23323bf0ca5fd12a682f69b27b78dff44b..1f0932c1942f8079be11d263cd72624d102992cc 100644 --- a/tests/test_parquet_scripts.py +++ b/tests/test_parquet_scripts.py @@ -1,4 +1,5 @@ import pytest +import subprocess def test_merge_parquet_and_convert(): """ @@ -12,4 +13,8 @@ def test_merge_parquet_and_convert(): x = os.system("python ./scripts/postprocessing/merge_parquet.py --source ./tests/samples/parquet_files/singles/ --target ./tests/samples/parquet_files/merged/ --cats test_cat.json --skip-normalisation") x += os.system("python ./scripts/postprocessing/convert_parquet_to_root.py ./tests/samples/parquet_files/merged/merged.parquet ./tests/samples/parquet_files/merged/merged.root mc --cats category.json") + # clean up + subprocess.run("rm -r ./tests/samples/parquet_files/merged", shell=True) + subprocess.run("rm ./higgs_dna/category.json", shell=True) + assert x==0 diff --git a/tests/test_processors.py b/tests/test_processors.py index a208d0972043b4fc1ecf53721b5582c4aa1a4a91..e529ef9de72fe7213841491654dd3acce1895021 100644 --- a/tests/test_processors.py +++ b/tests/test_processors.py @@ -86,3 +86,5 @@ def test_processors(): processor_instance=processor_instance, ) + # clean up + subprocess.run("rm -r output", shell=True) diff --git a/tests/test_processors_creation.py b/tests/test_processors_creation.py index 5c485e97c1e810205ef3deb6f1a2e8c500b7023f..4c8943adad858b0ee4e6f4f9fe64ddb948f1f8fd 100644 --- a/tests/test_processors_creation.py +++ b/tests/test_processors_creation.py @@ -53,6 +53,9 @@ def test_processors_creation(): #subprocess.run(command) result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + # clean up + subprocess.run("rm -r EE_leak", shell=True) + if result.returncode != 0: print("Error running the script:") print(result.stderr)