most-telephone-75272
11/21/2023, 6:52 PM--with kubernetesmost-telephone-75272
11/21/2023, 6:53 PMfrom metaflow import (
FlowSpec,
Parameter,
card,
catch,
conda,
conda_base,
kubernetes,
project,
step,
)
from src.flows.decorators import apt_install_java, poetry_install
from src.flows.utils import notebook
@project(name="dnn")
@conda_base(python="3.10", packages={"poetry": "1.7.1"})
class NotebookFlow(FlowSpec):
...
@step
def start(self):
...
@kubernetes()
@card(type="html")
@catch(var="execute_notebook_error")
@poetry_install()
@apt_install_java()
@step
def execute_notebook(self):
...
@step
def check_execute_notebook_error(self):
...
@step
def end(self):
...
if __name__ == "__main__":
NotebookFlow()most-telephone-75272
11/21/2023, 6:54 PMUSER=alvaro poetry run python notebook_flow.py --package-suffixes .json,.toml,.ipynb,.lock --environment conda run --notebook_path pricing/DNN/general/DS-737/ARPPU_Model.py --workflow_id "DS-733" --model_id "DS-740" --model_type general --with kubernetesmost-telephone-75272
11/21/2023, 6:55 PMmost-telephone-75272
11/22/2023, 4:57 PMsalmon-smartphone-62113
12/01/2023, 10:15 PMpoetry_install decorator? this seems like something my team could use as wellmost-telephone-75272
12/05/2023, 8:32 AMdef poetry_install():
def decorator(function):
@wraps(function)
def wrapper(*args, **kwargs):
Path("/root/.pip").mkdir(exist_ok=True)
copy("pip.conf", "/root/.pip/pip.conf")
run(
[
f"{sys.exec_prefix}/bin/poetry",
"export",
"--without-hashes",
"-E",
"metaflow",
"-f",
"requirements.txt",
"-o",
"/tmp/requirements.txt",
]
).check_returncode()
run([sys.executable, "-m", "pip", "install", "-q", "-r", "/tmp/requirements.txt"]).check_returncode()
return function(*args, **kwargs)
return wrapper
return decoratormost-telephone-75272
12/05/2023, 8:33 AMmost-telephone-75272
12/05/2023, 8:33 AMsalmon-smartphone-62113
12/21/2023, 9:29 PMsalmon-smartphone-62113
12/21/2023, 9:31 PM