Bump a semantic model version
Why it matters Model registries and serving configs pin versions like this.
Model registries version artifacts with MAJOR.MINOR.PATCH.
Write bump_version(version, part). part is "major", "minor" or "patch". Bumping a part resets the parts to its right to 0. Return the new version string.
def bump_version(version, part)Example
bump_version("1.4.2", "minor") is "1.5.0".
Understand the idea
Model registries often use semantic versions MAJOR.MINOR.PATCH. A patch bump means a small fix, a minor bump means a compatible change, and a major bump means a breaking change, such as new input features. When you bump one part, every part to its right resets to 0. Worked example: from '2.3.9', a patch bump gives '2.3.10' (numbers, not single digits, so 9 becomes 10). A minor bump gives '2.4.0', resetting the patch. A major bump gives '3.0.0', resetting both minor and patch. Rule: split the string on '.', convert the three parts to integers, add 1 to the chosen part, set every part after it to 0, and join back with '.'. Treat the parts as integers, not characters, or '9' plus one becomes a wrong string. Keeping the old patch number after a minor bump is the common bug. Used in: model registries such as MLflow tags, packaging model artifacts, and release pipelines where the version tells serving code whether a model is safe to swap in.