Skip to content

Commit

Permalink
py-earth2mip: add new package (#43062)
Browse files Browse the repository at this point in the history
* py-earth2mip: add new package

* Fix audit tests

* Make things easier to concretize

* Make things easier to concretize

* Fix magics build

* Fix onnx build

* blacken

* cmake > py-cmake

* Fix onnxruntime build

* onnxruntime: remove unknown cmake vars

* Trick bazelisk into using Spack bazel

* Different deps for main

* protobuf: add v3.25.3

* Enforce upper bound on jaxlib version

* py-chex: add v0.1.85

* py-dm-haiku: add v0.0.12

* py-jax: add v0.4.25

* Older jaxlib doesn't build on ppc64le either
  • Loading branch information
adamjstewart committed Mar 11, 2024
1 parent 3934df6 commit 98162aa
Show file tree
Hide file tree
Showing 45 changed files with 781 additions and 101 deletions.
7 changes: 5 additions & 2 deletions var/spack/repos/builtin/packages/abseil-cpp/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class AbseilCpp(CMakePackage):

license("Apache-2.0")

version(
"20240116.1", sha256="3c743204df78366ad2eaf236d6631d83f6bc928d1705dd0000b872e53b73dc6a"
)
version(
"20230802.1", sha256="987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed"
)
Expand Down Expand Up @@ -71,8 +74,8 @@ class AbseilCpp(CMakePackage):
description="C++ standard used during compilation",
)

depends_on("cmake@3.10:", when="@2023:", type="build")
depends_on("cmake@3.5:", when="@2019:", type="build")
depends_on("cmake@3.10:", when="@20220907:", type="build")
depends_on("cmake@3.5:", when="@20190312:", type="build")
depends_on("cmake@3.1:", type="build")

def cmake_args(self):
Expand Down
17 changes: 14 additions & 3 deletions var/spack/repos/builtin/packages/magics/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class Magics(CMakePackage):
software MAGICS. Although completely redesigned in C++, it is intended
to be as backwards-compatible as possible with the Fortran interface."""

homepage = "https://software.ecmwf.int/wiki/display/MAGP/Magics"
homepage = "https://confluence.ecmwf.int/display/MAGP/Magics"
url = "https://confluence.ecmwf.int/download/attachments/3473464/Magics-4.2.4-Source.tar.gz?api=v2"
list_url = "https://software.ecmwf.int/wiki/display/MAGP/Releases"
list_url = "https://confluence.ecmwf.int/display/MAGP/Releases"

license("Apache-2.0")

# The policy on which minor releases remain available and which get deleted
# after a newer version becomes available is unclear.
version("4.15.3", sha256="1836e1e37534c556f55b5b13812a513091c2fa508b8c4f5a8b6842f07741f1a7")
version("4.9.3", sha256="c01ee7c4b05c5512e93e573748d2766d299fa1a60c226f2a0d0989f3d7c5239b")
version("4.4.0", sha256="544058cd334f3e28a16d00ea7811e13cdf282f9c1ebec2ad7868171d925abd24")
version("4.3.3", sha256="27d3de71cf41f3d557fd85dabaea2baaab34c4c6422a5b5b15071a6a53387601")
Expand Down Expand Up @@ -86,7 +87,7 @@ class Magics(CMakePackage):

# Even if netcdf is disabled and -DENABLE_NETCDF=OFF is set, building
# magics still requires legacy netcdf-cxx
depends_on("netcdf-cxx", when="@4.1.0:4.3.1")
conflicts("~netcdf", when="@4.1.0:4.3.1,4.15.3:")

# Optional dependencies
depends_on("netcdf-cxx", when="+netcdf")
Expand Down Expand Up @@ -151,3 +152,13 @@ def cmake_args(self):
args.append("-DENABLE_METVIEW=OFF")

return args

@property
def libs(self):
return find_libraries(["libMagPlus"], root=self.prefix, recursive=True)

@property
def headers(self):
hl = find_all_headers(self.prefix.include)
hl.directories = [self.prefix.include, self.prefix.include.magics]
return hl
1 change: 1 addition & 0 deletions var/spack/repos/builtin/packages/protobuf/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Protobuf(CMakePackage):

license("BSD-3-Clause")

version("3.25.3", sha256="da82be8acc5347c7918ef806ebbb621b24988f7e1a19b32cd7fc73bc29b59186")
version("3.24.3", sha256="2c23dee0bdbc36bd43ee457083f8f5560265d0815cc1c56033de3932843262fe")
version("3.23.3", sha256="5e4b555f72a7e3f143a7aff7262292500bb02c49b174351684bb70fc7f2a6d33")
version("3.22.2", sha256="2118051b4fb3814d59d258533a4e35452934b1ddb41230261c9543384cbb4dfc")
Expand Down
11 changes: 8 additions & 3 deletions var/spack/repos/builtin/packages/py-aiobotocore/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ class PyAiobotocore(PythonPackage):

license("Apache-2.0")

version("2.12.1", sha256="8706b28f16f93c541f6ed50352115a79d8f3499539f8d0bb70aa0f7a5379c1fe")
version("2.5.0", sha256="6a5b397cddd4f81026aa91a14c7dd2650727425740a5af8ba75127ff663faf67")
version("2.4.2", sha256="0603b74a582dffa7511ce7548d07dc9b10ec87bc5fb657eb0b34f9bd490958bf")
version("1.2.1", sha256="58cc422e65fc89f7cb78eca740d241ac8e15f39f6b308cc23152711e8a987d45")

depends_on("py-setuptools", type="build")
depends_on("py-botocore@1.34.41:1.34.51", when="@2.12.1", type=("build", "run"))
depends_on("py-botocore@1.27.59", when="@2.4.2", type=("build", "run"))
depends_on("py-botocore@1.19.52", when="@1.2.1", type=("build", "run"))
depends_on("py-botocore@1.29.76", when="@2.5.0", type=("build", "run"))
depends_on("py-aiohttp@3.3.1:", type=("build", "run"))
depends_on("py-wrapt@1.10.10:", type=("build", "run"))
depends_on("py-aioitertools@0.5.1:", type=("build", "run"))
depends_on("py-aiohttp@3.7.4:3", when="@2.12:", type=("build", "run"))
depends_on("py-aiohttp@3.3.1:", when="@:2.5", type=("build", "run"))
depends_on("py-wrapt@1.10.10:1", when="@2.12:", type=("build", "run"))
depends_on("py-wrapt@1.10.10:", when="@:2.5", type=("build", "run"))
depends_on("py-aioitertools@0.5.1:0", when="@2.12:", type=("build", "run"))
depends_on("py-aioitertools@0.5.1:", when="@:2.5", type=("build", "run"))
3 changes: 2 additions & 1 deletion var/spack/repos/builtin/packages/py-cdsapi/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@


class PyCdsapi(PythonPackage):
"""The Climate Data Store Application Program Interface is a service providing programmatic access to CDS data. Get your UID and API key from the CDS portal at the address https://cds.climate.copernicus.eu/user and write it into the configuration file. Look at https://pypi.org/project/cdsapi/ for an example"""
"""Climate Data Store API."""

homepage = "https://cds.climate.copernicus.eu"
pypi = "cdsapi/cdsapi-0.2.3.tar.gz"

license("Apache-2.0")

version("0.6.1", sha256="7d40c58e3fd3e75a8acdcdc81eab4ef9b6f763b2902ba01d7d1738f3652a5a30")
version("0.2.3", sha256="333b31ec263224399635db9b21a2e1a50cd73451f5179f8d967437e7c9161d9b")

depends_on("py-setuptools", type="build")
Expand Down
13 changes: 9 additions & 4 deletions var/spack/repos/builtin/packages/py-cfgrib/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ class PyCfgrib(PythonPackage):

license("Apache-2.0")

version("0.9.10.4", sha256="b490078192aa13ec89c77296110355521442325866b16a996f4b3cf421542909")
version("0.9.9.0", sha256="6ff0227df9c5ee34aa7d6ab1f7af3fbe6838523a8a9891c74040b419b03ad289")
version("0.9.8.5", sha256="07c224d7ac823a1df5738b96b9d3621515538f51f67e55044f9cc8ec1668e1bd")

# Warning: can create infinite dependency loop with xarray+io ^cfgrib+xarray
variant("xarray", default=False, description="Add xarray support")

depends_on("python@3.5:", type=("build", "run"))
depends_on("py-setuptools", type="build")
depends_on("py-pytest-runner", when="@0.9.8.5", type="build")
depends_on("py-attrs@19.2:", type=("build", "run"))
depends_on("py-cffi", when="@0.9.8.5", type=("build", "run"))
depends_on("py-click", type=("build", "run"))
depends_on("py-eccodes@0.9.8:", when="@0.9.10:", type=("build", "run"))
depends_on("py-eccodes", type=("build", "run"))
depends_on("py-numpy", type=("build", "run"))
depends_on("py-xarray@0.12.0:", when="+xarray", type=("build", "run"))

depends_on("py-xarray@0.15:", when="@0.9.10:+xarray", type=("build", "run"))
depends_on("py-xarray@0.12:", when="+xarray", type=("build", "run"))

# Historical dependencies
depends_on("py-pytest-runner", when="@0.9.8.5", type="build")
depends_on("py-cffi", when="@0.9.8.5", type=("build", "run"))

@property
def import_modules(self):
Expand Down
14 changes: 12 additions & 2 deletions var/spack/repos/builtin/packages/py-chex/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ class PyChex(PythonPackage):

license("Apache-2.0")

version("0.1.85", sha256="a27cfe87119d6e1fe24ccc1438a59195e6dc1d6e0e10099fcf618c3f64771faf")
version("0.1.5", sha256="686858320f8f220c82a6c7eeb54dcdcaa4f3d7f66690dacd13a24baa1ee8299e")
version("0.1.0", sha256="9e032058f5fed2fc1d5e9bf8e12ece5910cf6a478c12d402b6d30984695f2161")

depends_on("python@3.7:", type=("build", "run"))
depends_on("python@3.9:", type=("build", "run"), when="@0.1.85:")
depends_on("py-setuptools", type="build")
depends_on("py-absl-py@0.9.0:", type=("build", "run"))
depends_on("py-dm-tree@0.1.5:", type=("build", "run"))
depends_on("py-typing-extensions@4.2:", type=("build", "run"), when="@0.1.85:")
depends_on("py-jax@0.4.16:", type=("build", "run"), when="@0.1.85:")
depends_on("py-jax@0.1.55:", type=("build", "run"))
depends_on("py-jaxlib@0.1.37:", type=("build", "run"))
depends_on("py-numpy@1.24.1:", type=("build", "run"), when="@0.1.85:")
depends_on("py-numpy@1.18.0:", type=("build", "run"))
depends_on("py-setuptools", type=("build", "run"), when="@0.1.85: ^python@3.12:")
depends_on("py-toolz@0.9.0:", type=("build", "run"))

# Historical dependencies
depends_on("py-dm-tree@0.1.5:", type=("build", "run"), when="@:0.1.5")

# AttributeError: module 'jax.interpreters.pxla' has no attribute 'ShardedDeviceArray'
conflicts("^py-jax@0.4.14:", when="@:0.1.5")
19 changes: 19 additions & 0 deletions var/spack/repos/builtin/packages/py-colabtools/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class PyColabtools(PythonPackage):
"""Tools to work with colab from google."""

homepage = "https://github.com/zuuuhkrit/colabtools"
pypi = "colabtools/colabtools-0.0.1.tar.gz"

license("LGPL-3.0-only")

version("0.0.1", sha256="b6f7c0050e5924f4ad7e4762d46be663e21d417a39fc4adf6c6c90e8d9be47ec")

depends_on("py-setuptools", type="build")
25 changes: 20 additions & 5 deletions var/spack/repos/builtin/packages/py-dm-haiku/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,31 @@ class PyDmHaiku(PythonPackage):

license("Apache-2.0")

version("0.0.12", sha256="ba0b3acf71433156737fe342c486da11727e5e6c9e054245f4f9b8f0b53eb608")
version("0.0.7", sha256="86c34af6952a305a4bbfda6b9925998577acc4aa2ad9333da3d6047f4f8ed7c1")
version("0.0.5", sha256="e986237e1f840aa3bd26217ecad84b611bf1456e2139f0f79ea71f9c6222d231")
depends_on("python@3.7:", type=("build", "run"))

variant("jax", default=False, description="Build with JAX support", when="@0.0.12:")

# setup.py
depends_on("python@3.9:", when="@0.0.12:", type=("build", "run"))
depends_on("py-setuptools", type="build")

# requirements.txt
depends_on("py-absl-py@0.7.1:", type=("build", "run"))
depends_on("py-jmp@0.0.2:", type=("build", "run"))
depends_on("py-numpy@1.18.0:", type=("build", "run"))
depends_on("py-tabulate@0.8.9:", type=("build", "run"))
depends_on("py-flax@0.7.1:", when="@0.0.12:", type=("build", "run"))

# requirements-jax.txt
with when("+jax"):
depends_on("py-jax@0.4.24:", type=("build", "run"))
depends_on("py-jaxlib@0.4.24:", type=("build", "run"))

# Historical dependencies
depends_on("py-typing-extensions", when="^python@:3.7", type=("build", "run"))
# from README.md:
# Because JAX installation is different depending on your CUDA version, Haiku does
# not list JAX as a dependency in `requirements.txt`.
depends_on("py-jax", type=("build", "run"))
depends_on("py-jax", when="@:0.0.7", type=("build", "run"))

# AttributeError: module 'jax' has no attribute 'xla'
conflicts("^py-jax@0.4.14:", when="@:0.0.7")
83 changes: 83 additions & 0 deletions var/spack/repos/builtin/packages/py-earth2mip/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class PyEarth2mip(PythonPackage):
"""Earth-2 Model Intercomparison Project (MIP).
A python framework that enables climate researchers and scientists to explore
and experiment with AI models for weather and climate.
"""

homepage = "https://github.com/NVIDIA/earth2mip"
url = "https://github.com/NVIDIA/earth2mip/archive/refs/tags/v0.1.0.tar.gz"
git = "https://github.com/NVIDIA/earth2mip.git"

maintainers("adamjstewart")

license("Apache-2.0")

version("main", branch="main")
version("0.1.0", sha256="a49d0607893013783d30bfcb2f80412014ab535fbcc1e96dd139b78819bd98ab")

variant("pangu", default=False, description="Build dependencies needed for Pangu-Weather")
variant("graphcast", default=False, description="Build dependencies needed for GraphCast")

with default_args(type="build"):
depends_on("py-setuptools")
depends_on("py-setuptools-scm")

with default_args(type=("build", "run")):
depends_on("python@3.10:")
depends_on("py-altair@4.2.2:")
depends_on("py-boto3@1.26.0:", when="@main")
depends_on("py-cdsapi@0.6.1:")
depends_on("py-cfgrib@0.9.10.3:")
depends_on("py-cftime")
depends_on("py-dask@2023.1.0:")
depends_on("py-distributed@2023.1.0:")
depends_on("py-eccodes@1.4.0:")
depends_on("py-ecmwflibs@0.5.2:")
depends_on("py-ecmwf-opendata@0.2.0:", when="@main")
depends_on("py-einops")
depends_on("py-fsspec")
depends_on("py-h5py@3.2.0:")
depends_on("py-h5netcdf@1.0.0:")
depends_on("py-importlib-metadata@6.7.0:")
depends_on("py-joblib@1.1.0:")
depends_on("py-loguru@0.6.0:", when="@main")
depends_on("py-netcdf4@1.6.4:")
depends_on("py-numpy")
depends_on("py-nvidia-modulus@0.4.0:")
depends_on("py-pandas@1.5.3:")
depends_on("py-properscoring@0.1:")
depends_on("py-pydantic@1.10:1.10.11")
depends_on("py-pytest-timeout@2.1.0:", when="@main")
depends_on("py-pytest-asyncio@0.21.0:")
depends_on("py-pytest-regtest")
depends_on("py-pytest@7.0.0:")
depends_on("py-python-dotenv@1.0.0:")
depends_on("py-s3fs")
depends_on("py-setuptools@38.4:")
depends_on("py-torch@1.13:")
depends_on("py-torch-harmonics@0.5.0:")
depends_on("py-tqdm@4.65.0:")
depends_on("py-typer")
depends_on("py-xarray")
depends_on("py-xskillscore@0.0.24:")
depends_on("py-zarr@2.14.2:")

with default_args(type="run"):
with when("+pangu"):
depends_on("py-onnxruntime@1.15.1:")

with when("+graphcast"):
depends_on("py-flax@0.7.3", when="@main")
depends_on("py-jax@0.4.16")
depends_on("py-graphcast@0.1")
depends_on("py-gcsfs")
depends_on("py-gcsfs@2023.6.0:", when="@0.1.0")
20 changes: 20 additions & 0 deletions var/spack/repos/builtin/packages/py-ecmwf-opendata/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class PyEcmwfOpendata(PythonPackage):
"""A package to download ECMWF open data."""

homepage = "https://github.com/ecmwf/ecmwf-opendata"
pypi = "ecmwf-opendata/ecmwf-opendata-0.3.3.tar.gz"

license("Apache-2.0")

version("0.3.3", sha256="6f3181c7872b72e5529d2b4b7ec6ff08d37c37beee0a498f7f286410be178c6a")

depends_on("py-setuptools", type="build")
depends_on("py-multiurl@0.2.1:", type=("build", "run"))
34 changes: 34 additions & 0 deletions var/spack/repos/builtin/packages/py-ecmwflibs/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class PyEcmwflibs(PythonPackage):
"""A Python package that wraps some of ECMWF libraries to be used by
Python interfaces to ECMWF software.
"""

homepage = "https://github.com/ecmwf/ecmwflibs"
url = "https://github.com/ecmwf/ecmwflibs/archive/refs/tags/0.6.1.tar.gz"

license("Apache-2.0")

version("0.6.1", sha256="9f2153d1b4a07038b975b7d6bb89bbf9e88d6bc4e2ef4d4e067e58a2fb5270d3")

depends_on("py-setuptools", type="build")
depends_on("py-findlibs", type=("build", "run"))
depends_on("eccodes")
depends_on("magics")

def patch(self):
# Instruct setup.py where to find dependencies
library_dirs = self.spec["eccodes"].libs.directories + self.spec["magics"].libs.directories
include_dirs = (
self.spec["eccodes"].headers.directories + self.spec["magics"].headers.directories
)
setup = FileFilter("setup.py")
setup.filter("library_dirs=.*", f"library_dirs={library_dirs},")
setup.filter("include_dirs=.*", f"include_dirs={include_dirs},")
19 changes: 14 additions & 5 deletions var/spack/repos/builtin/packages/py-etils/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ class PyEtils(PythonPackage):

license("Apache-2.0")

version("1.7.0", sha256="97b68fd25e185683215286ef3a54e38199b6245f5fe8be6bedc1189be4256350")
version("0.9.0", sha256="489103e9e499a566765c60458ee15d185cf0065f2060a4d16a68f8f46962ed0d")

variant("epath", default=False, description="with epath module")
variant("epy", default=False, description="with epy module")

depends_on("python@3.7:", type=("build", "run"))
depends_on("python@3.10:", type=("build", "run"), when="@1.7:")
depends_on("py-flit-core@3.8:3", type="build", when="@1.7:")
depends_on("py-flit-core@3.5:3", type="build")

depends_on("py-importlib-resources", type=("build", "run"), when="+epath")
depends_on("py-typing-extensions", type=("build", "run"), when="+epath")
depends_on("py-zipp", type=("build", "run"), when="+epath")
conflicts("~epy", when="+epath")

depends_on("py-flit-core@3.5:3", type="build")
with when("+epath"):
depends_on("py-fsspec", type=("build", "run"), when="@1.7:")
depends_on("py-importlib-resources", type=("build", "run"))
depends_on("py-typing-extensions", type=("build", "run"))
depends_on("py-zipp", type=("build", "run"))

with when("+epy"):
depends_on("py-typing-extensions", type=("build", "run"))

0 comments on commit 98162aa

Please sign in to comment.