plain-baker-2104
12/15/2022, 1:36 PMancient-application-36103
12/15/2022, 5:36 PMancient-application-36103
12/15/2022, 5:38 PM@pip - can you share your implementation of @pip ?plain-baker-2104
12/15/2022, 5:40 PMdef pip(libraries):
"""Work around to use pip in metaflow steps,
see here: <https://github.com/Netflix/metaflow/issues/24>"""
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
import subprocess
import sys
for library, version in libraries.items():
print("Pip Install:", library, version)
subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
# "--quiet",
library + "==" + version,
]
)
return function(*args, **kwargs)
return wrapper
return decoratorplain-baker-2104
12/15/2022, 5:48 PM--quiet , the last log line I see is Successfully installed XXX.
[and I have added a log step at the start of my start step] which is never outputplain-baker-2104
12/15/2022, 5:52 PMancient-application-36103
12/15/2022, 5:55 PMps -ef | grep metaflow ?fresh-laptop-72652
12/15/2022, 6:03 PMplain-baker-2104
12/15/2022, 6:04 PMfresh-laptop-72652
12/15/2022, 6:17 PM@pip in combination with a foreach fanout, as you might be spamming pypi servers or be downloading more than intended each time depending on the package (e.g. large libs or pretrained models), none of which will be persisted/versioned by metaflow or in the base python environment in the docker image.
also if you have both @conda and @pip decorators, this decorator needs to be placed after the @conda decorator to work correctly.plain-baker-2104
12/15/2022, 9:35 PMpip. we have been using it without problems for ? 2 years. I was assuming its related to a silent fail in the initialisation of the metaflow step.