diff --git a/pkgs/development/python-modules/codecarbon/default.nix b/pkgs/development/python-modules/codecarbon/default.nix new file mode 100644 index 000000000000..73407458e071 --- /dev/null +++ b/pkgs/development/python-modules/codecarbon/default.nix @@ -0,0 +1,152 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + setuptools, + + # dependencies + arrow, + authlib, + click, + nvidia-ml-py, + pandas, + prometheus-client, + psutil, + py-cpuinfo, + pycountry, + pydantic, + questionary, + rapidfuzz, + requests, + rich, + typer, + + # optional-dependencies + amdsmi, + dash, + dash-bootstrap-components, + fire, + + # tests + bcrypt, + dependency-injector, + email-validator, + fastapi, + fastapi-pagination, + httpx, + jwt, + logfire, + psycopg2, + pydantic-settings, + pytestCheckHook, + requests-mock, + responses, + sqlalchemy, +}: + +buildPythonPackage (finalAttrs: { + pname = "codecarbon"; + version = "3.2.6"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "mlco2"; + repo = "codecarbon"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Nzt+CKXnv6zvWKsFD7duguVj0AA4eWZgFUlBdIEujD8="; + }; + + build-system = [ + setuptools + ]; + + dependencies = [ + arrow + authlib + click + nvidia-ml-py + pandas + prometheus-client + psutil + py-cpuinfo + pycountry + pydantic + questionary + rapidfuzz + requests + rich + typer + ]; + + optional-dependencies = { + amdsmi = [ + amdsmi + ]; + carbonboard = [ + dash + dash-bootstrap-components + fire + ]; + viz-legacy = [ + dash + dash-bootstrap-components + fire + ]; + }; + + pythonImportsCheck = [ "codecarbon" ]; + + nativeBuildInputs = [ + bcrypt + dash + dependency-injector + email-validator + fastapi + fastapi-pagination + httpx + jwt + logfire + psycopg2 + pydantic-settings + pytestCheckHook + requests-mock + responses + sqlalchemy + ]; + + enabledTestPaths = [ + "carbonserver/tests/" + ]; + + disabledTestPaths = [ + # Fail in the sandbox: + # FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj' + "examples/" + + # _pytest.outcomes.Exit: CODECARBON_API_URL is not defined + "carbonserver/tests/api/integration/test_api_black_box.py" + + # Require unpackaged (and unmaintained) fief-client + "carbonserver/tests/api/routers/" + "carbonserver/tests/api/service/test_auth_provider.py" + + # Require internet access + "carbonserver/tests/api/integration/test_project_cascade_delete.py" + ]; + + disabledTests = [ + # AttributeError: does not have the attribute 'decode' + "test_check_user_from_jwt" + ]; + + meta = { + description = "Track emissions from Compute and recommend ways to reduce their impact on the environment"; + homepage = "https://github.com/mlco2/codecarbon"; + changelog = "https://github.com/mlco2/codecarbon/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/development/python-modules/dependency-injector/default.nix b/pkgs/development/python-modules/dependency-injector/default.nix index 25279d246c36..1f546cd80f48 100644 --- a/pkgs/development/python-modules/dependency-injector/default.nix +++ b/pkgs/development/python-modules/dependency-injector/default.nix @@ -1,34 +1,45 @@ { lib, - aiohttp, buildPythonPackage, - fastapi, fetchFromGitHub, + + # build-system + cython, + setuptools, + + # optional-dependencies + aiohttp, + pydantic, flask, + pyyaml, + + # tests + fastapi, httpx, mypy-boto3-s3, numpy, - pydantic, pytest-asyncio, pytestCheckHook, - pyyaml, scipy, - setuptools, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "dependency-injector"; - version = "4.48.3"; + version = "4.49.0"; pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "ets-labs"; repo = "python-dependency-injector"; - tag = version; - hash = "sha256-J4M4SM256vZa2JUhagcbKu+DAUk1Op9HN+WpLL6ScBc="; + tag = finalAttrs.version; + hash = "sha256-oL+Vgz2EOD/w385MJy+hLfkSctLEKRrzbx5RP9N8AmY="; }; - build-system = [ setuptools ]; + build-system = [ + cython + setuptools + ]; optional-dependencies = { aiohttp = [ aiohttp ]; @@ -46,7 +57,7 @@ buildPythonPackage rec { pytestCheckHook scipy ] - ++ lib.concatAttrValues optional-dependencies; + ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies; pythonImportsCheck = [ "dependency_injector" ]; @@ -56,15 +67,16 @@ buildPythonPackage rec { "tests/unit/wiring/test_*_py36.py" "tests/unit/providers/configuration/test_from_pydantic_py36.py" "tests/unit/providers/configuration/test_pydantic_settings_in_init_py36.py" + + # Requires unpackaged fast-depends + "tests/unit/wiring/test_fastdepends.py" ]; meta = { description = "Dependency injection microframework for Python"; homepage = "https://github.com/ets-labs/python-dependency-injector"; - changelog = "https://github.com/ets-labs/python-dependency-injector/blob/${src.tag}/docs/main/changelog.rst"; + changelog = "https://github.com/ets-labs/python-dependency-injector/blob/${finalAttrs.src.tag}/docs/main/changelog.rst"; license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ gerschtli ]; - # https://github.com/ets-labs/python-dependency-injector/issues/726 - broken = lib.versionAtLeast pydantic.version "2"; }; -} +}) diff --git a/pkgs/development/python-modules/fastapi-pagination/default.nix b/pkgs/development/python-modules/fastapi-pagination/default.nix new file mode 100644 index 000000000000..b00f868fac28 --- /dev/null +++ b/pkgs/development/python-modules/fastapi-pagination/default.nix @@ -0,0 +1,50 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + hatchling, + + # dependencies + fastapi, + pydantic, + typing-extensions, +}: + +buildPythonPackage (finalAttrs: { + pname = "fastapi-pagination"; + version = "0.15.12"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "uriyyo"; + repo = "fastapi-pagination"; + tag = finalAttrs.version; + hash = "sha256-AzpNyTzlzPHkrx8BghZFHer3w+GpNIUYRo15rRRO0UY="; + }; + + build-system = [ + hatchling + ]; + + dependencies = [ + fastapi + pydantic + typing-extensions + ]; + + pythonImportsCheck = [ "fastapi_pagination" ]; + + # Tests require network access + doCheck = false; + + meta = { + description = "FastAPI pagination"; + homepage = "https://github.com/uriyyo/fastapi-pagination"; + changelog = "https://github.com/uriyyo/fastapi-pagination/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/development/python-modules/pytorch-bench/default.nix b/pkgs/development/python-modules/pytorch-bench/default.nix index 3b8e1551947b..6748a0e1f3f0 100644 --- a/pkgs/development/python-modules/pytorch-bench/default.nix +++ b/pkgs/development/python-modules/pytorch-bench/default.nix @@ -2,43 +2,61 @@ lib, buildPythonPackage, fetchFromGitHub, + + # build-system setuptools, + + # dependencies + codecarbon, colorama, matplotlib, numpy, - pynvml, + nvidia-ml-py, torch, torchprofile, + tqdm, + + # passthru + nix-update-script, }: buildPythonPackage { pname = "pytorch-bench"; - version = "unstable-2024-07-18"; + version = "0-unstable-2025-05-05"; pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "MaximeGloesener"; repo = "torch-benchmark"; - rev = "405a3fc2d147b43b4c1f7edb7aca0a60ba343ac5"; - hash = "sha256-KU3dAf97A6lkMNTKRay23BMFQfn1ReAFNaJ0kG2RfnA="; + rev = "f22db3b2e5920cf084e088e7748e3ffd32343853"; + hash = "sha256-+jd+H5hL+DotlLaBiaixb//hxyvEF6aAJYSHX1hfsP8="; }; build-system = [ setuptools ]; + pythonRemoveDeps = [ + # pynvml is deprecated and replaced by nvidia-ml-py which provides the same API + "pynvml" + ]; dependencies = [ + codecarbon colorama matplotlib numpy - pynvml + nvidia-ml-py torch torchprofile + tqdm ]; - pythonImportsCheck = [ - "pytorch_bench" - ]; + pythonImportsCheck = [ "pytorch_bench" ]; + + passthru.updateScript = nix-update-script { + extraArgs = [ "--version=branch" ]; + }; meta = { description = "Benchmarking tool for torch"; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0443a3664d6a..75a1ff10b2df 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2978,6 +2978,8 @@ self: super: with self; { cocotb-bus = callPackage ../development/python-modules/cocotb-bus { }; + codecarbon = callPackage ../development/python-modules/codecarbon { }; + codepy = callPackage ../development/python-modules/codepy { }; coffea = callPackage ../development/python-modules/coffea { }; @@ -5421,6 +5423,8 @@ self: super: with self; { fastapi-mcp = callPackage ../development/python-modules/fastapi-mcp { }; + fastapi-pagination = callPackage ../development/python-modules/fastapi-pagination { }; + fastapi-sso = callPackage ../development/python-modules/fastapi-sso { }; fastapi-versionizer = callPackage ../development/python-modules/fastapi-versionizer { };