Skip to content

Instantly share code, notes, and snippets.

@cokeSchlumpf
Created March 24, 2023 09:46
Show Gist options
  • Save cokeSchlumpf/4d7f87aa5b9b9a8484e0d703d9c3abb3 to your computer and use it in GitHub Desktop.
Save cokeSchlumpf/4d7f87aa5b9b9a8484e0d703d9c3abb3 to your computer and use it in GitHub Desktop.
def mlflow_pip_deps() -> List[str]:
try:
poetry_export_result = subprocess.run(
["poetry", "export", "-f", "requirements.txt", "--without-hashes"],
capture_output=True,
encoding="utf8",
).stdout.splitlines()
result = []
for req in poetry_export_result:
# ignore extra/index url lines
if "index-url" in req:
continue
# remove the python version markers
result.append(
re.sub(
r'(( and )?python_version (>=|<=|==|<|>) "[\d.]+"( and)?)', "", req
)
)
print(result)
return result
except Exception as ex:
raise Exception(
"Make sure the 'poetry-plugin-export' is installed. Error: {0}".format(ex)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment