From 1f6a538e9f42894fcc51a91b6e2585a9316f5e5e Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 11 Nov 2024 06:23:29 +0300 Subject: [PATCH] attempt to use memray --- default.nix | 3 ++- flake.lock | 6 +++--- flake.nix | 4 +++- nixos/module.nix | 7 ++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index 93cd1d3..ced0bee 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ pythonPackages, rev ? "local" }: +{ pythonPackages, rev ? "local", pkgs }: pythonPackages.buildPythonPackage rec { pname = "selfprivacy-graphql-api"; @@ -22,6 +22,7 @@ pythonPackages.buildPythonPackage rec { requests websockets httpx + pkgs.memray ]; pythonImportsCheck = [ "selfprivacy_api" ]; doCheck = false; diff --git a/flake.lock b/flake.lock index df8af1e..e154fd2 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1721949857, - "narHash": "sha256-DID446r8KsmJhbCzx4el8d9SnPiE8qa6+eEQOJ40vR0=", + "lastModified": 1731295185, + "narHash": "sha256-RaK3jMQ6X8FVESUSURB2An9FYmCfh3nEy8sUyxc/nJk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a1cc729dcbc31d9b0d11d86dc7436163548a9665", + "rev": "87e3803821210c537acfce075adf5cd030e963b3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d77dfde..deee2d6 100644 --- a/flake.nix +++ b/flake.nix @@ -8,8 +8,9 @@ system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; selfprivacy-graphql-api = pkgs.callPackage ./default.nix { - pythonPackages = pkgs.python312Packages; + pythonPackages = pkgs.python311Packages; rev = self.shortRev or self.dirtyShortRev or "dirty"; + pkgs = pkgs; }; python = self.packages.${system}.default.pythonModule; python-env = @@ -29,6 +30,7 @@ pyflakes typer # for strawberry types-redis # for mypy + pkgs.memray ] ++ strawberry-graphql.optional-dependencies.cli)); vmtest-src-dir = "/root/source"; diff --git a/nixos/module.nix b/nixos/module.nix index 0203bf0..b982b5f 100644 --- a/nixos/module.nix +++ b/nixos/module.nix @@ -45,12 +45,13 @@ in pkgs.util-linux pkgs.e2fsprogs pkgs.iproute2 + pkgs.memray ]; after = [ "network-online.target" ]; wantedBy = [ "network-online.target" ]; serviceConfig = { User = "root"; - ExecStart = "${selfprivacy-graphql-api}/bin/app.py"; + ExecStart = "${pkgs.memray}/bin/memray --trace-python-allocators --live-remote ${selfprivacy-graphql-api}/bin/app.py"; Restart = "always"; RestartSec = "5"; }; @@ -61,7 +62,7 @@ in HOME = "/root"; PYTHONUNBUFFERED = "1"; PYTHONPATH = - pkgs.python312Packages.makePythonPath [ selfprivacy-graphql-api ]; + pkgs.python311Packages.makePythonPath [ selfprivacy-graphql-api ]; } // config.networking.proxy.envVars; path = [ "/var/" @@ -82,7 +83,7 @@ in wantedBy = [ "network-online.target" ]; serviceConfig = { User = "root"; - ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey"; + ExecStart = "${pkgs.python311Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey"; Restart = "always"; RestartSec = "5"; };