Created
March 24, 2023 09:46
-
-
Save cokeSchlumpf/4d7f87aa5b9b9a8484e0d703d9c3abb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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