From 24f40e2a46366b2de53b62f5ec5f2be24b7a337e Mon Sep 17 00:00:00 2001 From: Tom Body Date: Thu, 18 Jul 2024 11:50:02 -0400 Subject: [PATCH] Add meson and ninja to environment --- poetry.lock | 44 +++++++++++++++++++- pyproject.toml | 2 + radas/adas_interface/prepare_adas_readers.py | 2 +- radas/cli.py | 41 +++++++++++++----- 4 files changed, 76 insertions(+), 13 deletions(-) diff --git a/poetry.lock b/poetry.lock index ebfb255..7d68890 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1212,6 +1212,21 @@ files = [ {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, ] +[[package]] +name = "meson" +version = "1.5.0" +description = "A high performance build system" +optional = false +python-versions = ">=3.7" +files = [ + {file = "meson-1.5.0.tar.gz", hash = "sha256:45d7b8653c1e5139df35b33be2dd5b2d040c5b2c6129f9a7c890d507e33312b8"}, +] + +[package.extras] +ninja = ["ninja (>=1.8.2)"] +progress = ["tqdm"] +typing = ["mypy", "typing_extensions"] + [[package]] name = "more-itertools" version = "10.3.0" @@ -1270,6 +1285,33 @@ files = [ {file = "nh3-0.2.18.tar.gz", hash = "sha256:94a166927e53972a9698af9542ace4e38b9de50c34352b962f4d9a7d4c927af4"}, ] +[[package]] +name = "ninja" +version = "1.11.1.1" +description = "Ninja is a small build system with a focus on speed" +optional = false +python-versions = "*" +files = [ + {file = "ninja-1.11.1.1-py2.py3-none-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:376889c76d87b95b5719fdd61dd7db193aa7fd4432e5d52d2e44e4c497bdbbee"}, + {file = "ninja-1.11.1.1-py2.py3-none-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ecf80cf5afd09f14dcceff28cb3f11dc90fb97c999c89307aea435889cb66877"}, + {file = "ninja-1.11.1.1-py2.py3-none-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:84502ec98f02a037a169c4b0d5d86075eaf6afc55e1879003d6cab51ced2ea4b"}, + {file = "ninja-1.11.1.1-py2.py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:73b93c14046447c7c5cc892433d4fae65d6364bec6685411cb97a8bcf815f93a"}, + {file = "ninja-1.11.1.1-py2.py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:18302d96a5467ea98b68e1cae1ae4b4fb2b2a56a82b955193c637557c7273dbd"}, + {file = "ninja-1.11.1.1-py2.py3-none-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:aad34a70ef15b12519946c5633344bc775a7656d789d9ed5fdb0d456383716ef"}, + {file = "ninja-1.11.1.1-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:d491fc8d89cdcb416107c349ad1e3a735d4c4af5e1cb8f5f727baca6350fdaea"}, + {file = "ninja-1.11.1.1-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:7563ce1d9fe6ed5af0b8dd9ab4a214bf4ff1f2f6fd6dc29f480981f0f8b8b249"}, + {file = "ninja-1.11.1.1-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:9df724344202b83018abb45cb1efc22efd337a1496514e7e6b3b59655be85205"}, + {file = "ninja-1.11.1.1-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:3e0f9be5bb20d74d58c66cc1c414c3e6aeb45c35b0d0e41e8d739c2c0d57784f"}, + {file = "ninja-1.11.1.1-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:76482ba746a2618eecf89d5253c0d1e4f1da1270d41e9f54dfbd91831b0f6885"}, + {file = "ninja-1.11.1.1-py2.py3-none-win32.whl", hash = "sha256:fa2ba9d74acfdfbfbcf06fad1b8282de8a7a8c481d9dee45c859a8c93fcc1082"}, + {file = "ninja-1.11.1.1-py2.py3-none-win_amd64.whl", hash = "sha256:95da904130bfa02ea74ff9c0116b4ad266174fafb1c707aa50212bc7859aebf1"}, + {file = "ninja-1.11.1.1-py2.py3-none-win_arm64.whl", hash = "sha256:185e0641bde601e53841525c4196278e9aaf4463758da6dd1e752c0a0f54136a"}, + {file = "ninja-1.11.1.1.tar.gz", hash = "sha256:9d793b08dd857e38d0b6ffe9e6b7145d7c485a42dcfea04905ca0cdb6017cc3c"}, +] + +[package.extras] +test = ["codecov (>=2.0.5)", "coverage (>=4.2)", "flake8 (>=3.0.4)", "pytest (>=4.5.0)", "pytest-cov (>=2.7.1)", "pytest-runner (>=5.1)", "pytest-virtualenv (>=1.7.0)", "virtualenv (>=15.0.3)"] + [[package]] name = "numpy" version = "2.0.0" @@ -2351,4 +2393,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "<3.13,>=3.9" -content-hash = "49b443e32199023ecb9c5d54c635421f4fc9482f5cdbec826359e0e984855377" +content-hash = "5588c76e24e2b2572e3974918c6e7cb0817ff3cfaa98422b130e7c637ddb1a9b" diff --git a/pyproject.toml b/pyproject.toml index 07fd286..d3737ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,8 @@ pyyaml = ">=6.0" xarray = ">=2023" pint-xarray = ">=0.3" click = ">=8.1" +meson = "^1.5.0" +ninja = "^1.11.1.1" [tool.poetry.group.dev.dependencies] # Install pytest into all development environments diff --git a/radas/adas_interface/prepare_adas_readers.py b/radas/adas_interface/prepare_adas_readers.py index aaf6135..5255b85 100644 --- a/radas/adas_interface/prepare_adas_readers.py +++ b/radas/adas_interface/prepare_adas_readers.py @@ -77,7 +77,7 @@ def build_adas_file_reader( urllib.request.urlretrieve(query_path, output_filename) if verbose: print(f"Unpacking {output_filename} into {output_folder}") - shutil.unpack_archive(output_filename, output_folder) + shutil.unpack_archive(output_filename, output_folder, filter="data") else: if verbose: print(f"Reusing {query_path} ({output_filename} already exists)") diff --git a/radas/cli.py b/radas/cli.py index fca0d22..5a4d462 100644 --- a/radas/cli.py +++ b/radas/cli.py @@ -42,11 +42,17 @@ @click.option( "-v", "--verbose", count=True, help="Write additional output to the command line." ) +@click.option( + "--debug", + is_flag=True, + help="Flag to enable debug mode (disables multiprocessing).", +) def run_radas_cli( directory: Path, config: Optional[str], species: list[str], verbose: int, + debug: bool, ): """Runs the radas program. @@ -56,7 +62,13 @@ def run_radas_cli( If species is given, it must be a valid species name (i.e. 'hydrogen'). Otherwise, all valid species in the config.yaml file are evaluated. """ - kwargs = dict(directory=directory, config=config, species=species, verbose=verbose) + kwargs = dict( + directory=directory, + config=config, + species=species, + verbose=verbose, + debug=debug, + ) try: from ipdb import launch_ipdb_on_exception @@ -71,6 +83,7 @@ def run_radas( config: Optional[str], species: list[str], verbose: int, + debug: bool, ): radas_dir = Path(directory) @@ -122,16 +135,22 @@ def run_radas( ) output_dir.mkdir(exist_ok=True, parents=True) - with mp.Pool() as pool: - if species != ("all",): - datasets = { - species_name: datasets[species_name] for species_name in species - } - - pool.map( - partial(run_radas_computation, output_dir=output_dir, verbose=verbose), - [(ds) for ds in datasets.values()], - ) + if not debug: + with mp.Pool() as pool: + if species != ("all",): + datasets = { + species_name: datasets[species_name] for species_name in species + } + + pool.map( + partial( + run_radas_computation, output_dir=output_dir, verbose=verbose + ), + [(ds) for ds in datasets.values()], + ) + else: + for ds in datasets.values(): + run_radas_computation(ds, output_dir=output_dir, verbose=verbose) if verbose: print(f"Generating plots and saving output to {output_dir}")