{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Integrate with Git\n", "\n", "``rubicon_ml``'s ``git`` integration allows you to automatically track relevant version control\n", "information like branches and commits during your model iteration process. \n", "Use this integration when you are developing within a ``git`` repository to seamlessly tie\n", "your ``rubicon_ml`` experiments directly to the model code that produced them - an audit and\n", "governance must have!\n", "\n", "To enable this feature, instantiate the ``rubicon_ml`` object with ``auto_git_enabled=True``." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from rubicon_ml import Rubicon\n", "\n", "\n", "rubicon = Rubicon(persistence=\"memory\", auto_git_enabled=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Any **project** created with this client will have the URL of the GitHub repo's origin\n", "automatically populated in the `github_url` property." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'https://github.com/capitalone/rubicon-ml.git'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "project = rubicon.create_project(\"Automatic Git Integration\")\n", "\n", "project.github_url" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Experiments** will have the current active branch name and last commit hash populated in\n", "the ``branch_name`` and ``commit_hash`` fields, respectively." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('rubicon-ml', '7c76df58384ee03f231521e247b351386f8b3cd1')" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "experiment = project.log_experiment(model_name=\"GitHub Model\")\n", "\n", "experiment.branch_name, experiment.commit_hash" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These properties can help easily associate **projects** and **experiments** with the exact\n", "branches and commits they were run against so we can go back and reference the code later." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ " * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)\n", "127.0.0.1 - - [14/May/2021 11:58:45] \"GET /_alive_e9483f78-700c-4852-a59e-f027a3b5caf7 HTTP/1.1\" 200 -\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Dash app running on http://127.0.0.1:8050/\n" ] } ], "source": [ "from rubicon_ml.viz import Dashboard\n", "\n", "\n", "experiment.log_parameter(name=\"input\", value=True)\n", "experiment.log_metric(name=\"output\", value=1.0)\n", "\n", "Dashboard([experiment]).show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Within the ``rubicon_ml`` dashboard, your experiments will be grouped by\n", "commit hash, which will link directly to the commit on GitHub.\n", "\n", "![dashboard](integration-git-dashboard.png \"dashboard\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" } }, "nbformat": 4, "nbformat_minor": 4 }