Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to ensure dev/update_ml_package_versions.py is up-to-date #11671

Merged
merged 7 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ repos:
language: system
stages: [commit]
require_serial: true

- id: mlver
name: check
Copy link
Collaborator

@B-Step62 B-Step62 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: check
name: ml-package-version-consistency

Just to make the intention of the hook more visible, assuming there will be no additional message is shown about why the file is updated. WDYT?

Copy link
Member Author

@harupy harupy Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch, sounds good! updated

entry: "python dev/update_ml_package_versions.py --skip-yml"
files: '^(mlflow/ml-package-versions\.yml|mlflow/ml_package_versions\.py)$'
language: system
stages: [commit]
require_serial: true
pass_filenames: false
2 changes: 1 addition & 1 deletion dev/tests/test_update_ml_package_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def patch_urlopen(url):
versions_yaml.write_text(src)

with mock.patch("urllib.request.urlopen", new=patch_urlopen):
update_ml_package_versions.main()
update_ml_package_versions.update()

assert versions_yaml.read_text() == src_expected

Expand Down
54 changes: 35 additions & 19 deletions dev/update_ml_package_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# How to run (make sure you're in the repository root):
$ python dev/update_ml_package_versions.py
"""
import argparse
import json
import re
import urllib.request
Expand Down Expand Up @@ -150,33 +151,48 @@ def update_ml_package_versions_py(config_path):
)


def main():
def parse_args():
parser = argparse.ArgumentParser(description="Update MLflow package versions")
parser.add_argument(
"--skip-yml", action="store_true", help="Skip updating ml-package-versions.yml"
)
return parser.parse_args()


def update(skip_yml):
yml_path = "mlflow/ml-package-versions.yml"
old_src = read_file(yml_path)
new_src = old_src
config_dict = yaml.load(old_src, Loader=yaml.SafeLoader)

for flavor_key, config in config_dict.items():
for category in ["autologging", "models"]:
if (category not in config) or config[category].get("pin_maximum", False):
continue
print("Processing", flavor_key, category)
if not skip_yml:
old_src = read_file(yml_path)
new_src = old_src
config_dict = yaml.load(old_src, Loader=yaml.SafeLoader)
for flavor_key, config in config_dict.items():
for category in ["autologging", "models"]:
if (category not in config) or config[category].get("pin_maximum", False):
continue
print("Processing", flavor_key, category)

package_name = config["package_info"]["pip_release"]
max_ver = config[category]["maximum"]
versions = get_package_versions(package_name)
unsupported = config[category].get("unsupported", [])
versions = set(versions).difference(unsupported) # exclude unsupported versions
latest_version = get_latest_version(versions)
package_name = config["package_info"]["pip_release"]
max_ver = config[category]["maximum"]
versions = get_package_versions(package_name)
unsupported = config[category].get("unsupported", [])
versions = set(versions).difference(unsupported) # exclude unsupported versions
latest_version = get_latest_version(versions)

if Version(latest_version) <= Version(max_ver):
continue
if Version(latest_version) <= Version(max_ver):
continue

new_src = update_max_version(new_src, flavor_key, latest_version, category)

new_src = update_max_version(new_src, flavor_key, latest_version, category)
save_file(new_src, yml_path)

save_file(new_src, yml_path)
update_ml_package_versions_py(yml_path)


def main():
args = parse_args()
update(args.skip_yml)


if __name__ == "__main__":
main()
17 changes: 13 additions & 4 deletions mlflow/ml_package_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"pip_release": "pytorch-lightning"
},
"autologging": {
"minimum": "1.4.9",
"minimum": "1.9.0",
"maximum": "2.2.0.post0"
}
},
Expand Down Expand Up @@ -129,7 +129,7 @@
"pip_release": "onnx"
},
"models": {
"minimum": "1.7.0",
"minimum": "1.13.1",
"maximum": "1.15.0"
}
},
Expand Down Expand Up @@ -160,11 +160,11 @@
"pip_release": "pyspark"
},
"models": {
"minimum": "3.0.0",
"minimum": "3.1.2",
"maximum": "3.5.1"
},
"autologging": {
"minimum": "3.0.0",
"minimum": "3.1.2",
"maximum": "3.5.1"
}
},
Expand Down Expand Up @@ -283,5 +283,14 @@
"minimum": "4.4.6",
"maximum": "5.2.8"
}
},
"promptflow": {
"package_info": {
"pip_release": "promptflow"
},
"models": {
"minimum": "1.3.0",
"maximum": "1.6.0"
}
}
}