depot/third_party/nixpkgs/pkgs/servers/mlflow-server/default.nix
Default email 727493fff0 Project import generated by Copybara.
GitOrigin-RevId: b839d4a8557adc80e522f674529e586ab2a88d23
2020-11-09 16:59:12 +01:00

37 lines
995 B
Nix

{lib, python3, writeText}:
let
py = python3.pkgs;
in
py.toPythonApplication
(py.mlflow.overridePythonAttrs(old: rec {
pname = "mlflow-server";
propagatedBuildInputs = old.propagatedBuildInputs ++ [
py.boto3
py.mysqlclient
];
postPatch = ''
substituteInPlace mlflow/utils/process.py --replace \
"child = subprocess.Popen(cmd, env=cmd_env, cwd=cwd, universal_newlines=True," \
"cmd[0]='$out/bin/gunicornMlflow'; child = subprocess.Popen(cmd, env=cmd_env, cwd=cwd, universal_newlines=True,"
'';
gunicornScript = writeText "gunicornMlflow"
''
#!/usr/bin/env python
import re
import sys
from gunicorn.app.wsgiapp import run
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', ''', sys.argv[0])
sys.exit(run())
'';
postInstall = ''
gpath=$out/bin/gunicornMlflow
cp ${gunicornScript} $gpath
chmod 555 $gpath
'';
}))