{"id":3507,"library":"gto","title":"GTO (Git Tag Ops)","description":"GTO (Git Tag Ops) is an open-source Python library designed to transform your Git repository into an Artifact Registry, particularly suited for Machine Learning models. It facilitates tracking new artifact versions, managing their lifecycle through defined stages, and automating integrations with CI/CD systems using a Git-native approach. The library is currently at version 1.9.0 and maintains a steady release cadence with frequent minor and patch updates.","status":"active","version":"1.9.0","language":"en","source_language":"en","source_url":"https://github.com/iterative/gto","tags":["MLOps","GitOps","versioning","models","artifacts","registry"],"install":[{"cmd":"pip install gto","lang":"bash","label":"Install GTO"}],"dependencies":[{"reason":"GTO requires Python 3.9 or higher.","package":"python","optional":false},{"reason":"Used for data validation and settings management. Version 2.x is required since GTO 1.9.0.","package":"pydantic","optional":false},{"reason":"Core dependency for Git repository operations. Version 3.x is required since GTO 1.7.0.","package":"scmrepo","optional":false},{"reason":"Frequently used alongside GTO to manage data and model files, serving as a backbone for Git-based Iterative Studio Model Registry.","package":"dvc","optional":true}],"imports":[{"note":"Primary import for accessing GTO's CLI and API functionality.","symbol":"gto","correct":"import gto"},{"note":"For direct programmatic access to GTO's operations like register, show, assign, etc.","symbol":"gto.api","correct":"from gto import api"}],"quickstart":{"code":"import os\nfrom pathlib import Path\nimport tempfile\nimport shutil\nfrom gto import api\n\n# Create a temporary directory for a mock Git repo\noriginal_cwd = os.getcwd()\ntemp_dir = Path(tempfile.mkdtemp())\nos.chdir(temp_dir)\n\ntry:\n    # Initialize a Git repository\n    os.system('git init -b main')\n    os.system('git config user.email \"test@example.com\"')\n    os.system('git config user.name \"Test User\"')\n    \n    # Create a dummy artifact file\n    (temp_dir / \"model.pkl\").write_text(\"dummy_model_content\")\n    os.system('git add .')\n    os.system('git commit -m \"Initial commit with model.pkl\"')\n\n    # Register a new version of an artifact\n    print(\"\\n--- Registering artifact 'my-model' ---\")\n    api.register(\"my-model\", \"model.pkl\", type=\"model\", description=\"My first model\")\n    print(\"Artifact registered successfully.\\n\")\n\n    # Show the current state of the artifact registry\n    print(\"\\n--- Showing artifact registry state ---\")\n    registry_state = api.show(name=\"my-model\", json=True)\n    print(registry_state)\n\n    # Promote the artifact to a 'dev' stage\n    print(\"\\n--- Promoting 'my-model' to 'dev' stage ---\")\n    api.assign(\"my-model\", stage=\"dev\", version=\"my-model@v0.0.1\")\n    print(\"Artifact promoted to 'dev' stage successfully.\\n\")\n\n    # Show the updated state\n    print(\"\\n--- Showing updated registry state ---\")\n    updated_registry_state = api.show(name=\"my-model\", json=True)\n    print(updated_registry_state)\n\n    # Important: Push the Git tags for changes to be reflected remotely\n    # In a real scenario: os.system('git push origin --tags')\n\nfinally:\n    os.chdir(original_cwd)\n    shutil.rmtree(temp_dir)","lang":"python","description":"This quickstart demonstrates how to use the `gto.api` to register an artifact and assign it to a stage within a Git repository. It simulates a basic Git workflow, registers 'my-model' from a 'model.pkl' file, and then promotes it to a 'dev' stage, finally showing the registry's state. Note that in a real scenario, `git push --tags` would be necessary to synchronize the GTO-managed tags with a remote repository."},"warnings":[{"fix":"Upgrade your Python interpreter to version 3.9 or higher. Review Python's official documentation for migration guidance if moving from significantly older versions.","message":"GTO dropped support for Python 3.8 in version 1.7.0. Users running GTO on Python 3.8 or older versions will encounter installation or runtime errors and must upgrade their Python environment to 3.9 or newer.","severity":"breaking","affected_versions":">=1.7.0"},{"fix":"Upgrade all Pydantic-dependent code and libraries to Pydantic V2. Utilize `bump-pydantic` tool for automated code migration. If a full migration is not immediately feasible, Pydantic V2 offers a compatibility layer to import V1 features via `from pydantic.v1 import BaseModel`.","message":"GTO migrated to Pydantic V2 in version 1.9.0. This introduces significant breaking changes from Pydantic V1, affecting how models are defined, validated, and serialized. If your project has other dependencies pinning Pydantic V1 or directly uses Pydantic V1 APIs, this update will likely cause conflicts or runtime errors.","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"Ensure that if your project directly or indirectly depends on `scmrepo`, it is compatible with `scmrepo` version 3.x. Review `scmrepo`'s changelog for specific breaking changes in its 3.x release.","message":"GTO updated its internal `scmrepo` dependency to version 3.x in GTO 1.7.0. Major version bumps in `scmrepo` (a library for SCM operations) typically involve breaking API changes. While direct interaction with `scmrepo` might be abstracted by GTO, users who rely on internal `scmrepo` structures or have other `scmrepo`-dependent libraries might face compatibility issues.","severity":"breaking","affected_versions":">=1.7.0"},{"fix":"Always remember to run `git push origin --tags` after performing `gto register` or `gto assign` (or any other `gto` command that creates/modifies tags) to ensure your registry state is shared and persistent.","message":"GTO uses Git tags to store artifact versions and stage assignments. While `gto` commands create these tags locally, they are not automatically pushed to your remote Git repository. Failing to `git push --tags` means your artifact registry changes are not synchronized or visible to collaborators/CI/CD systems.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}