2

I'm new to mlflow and learning it from very beginning. I installed mlflow package in python, and run the following code in spyder.

import os
from random import random, randint

from mlflow import log_metric, log_param, log_artifacts

if __name__ == "__main__":
    print("Running mlflow_tracking.py")

    log_param("param1", randint(0, 100))

    log_metric("foo", random())
    log_metric("foo", random() + 1)
    log_metric("foo", random() + 2)

    if not os.path.exists("outputs"):
        os.makedirs("outputs")
    with open("outputs/test.txt", "w") as f:
        f.write("hello world!")

    log_artifacts("outputs")

This code should be standard and I run it for test. What makes me confused is that git-related error appears. No git connect is set up and no git file is called. Why is there such an error. By the way, I have ..\AppData\Local\GitHubDesktop\bin in path (is github the same as git here).

WARNING mlflow.utils.git_utils: Failed to import Git (the Git executable is probably not on your PATH), so Git SHA is not available. Error: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

Running mlflow_tracking.py

I searched the following link to fix this error by setting os.environ["GIT_PYTHON_REFRESH"] = "quiet".

git executable not found in python

Could anyone explain why it's this way and help to fix this issue. Thanks in advance.

3
  • ..\AppData\Local\GitHubDesktop\bin does this contain the git exe? If not, you need to install Git for Windows on your system, I'd think. Commented Jun 9, 2023 at 21:01
  • @RandomDavis You are right. I install git and It's fixed now. But still have no idea how git is involved in this code. Commented Jun 9, 2023 at 21:17
  • Usually that's when some code wants to download some additional libraries or repos. Commented Jun 9, 2023 at 21:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.