Skip to content

Commit

Permalink
Warning if git is not installed (#1414)
Browse files Browse the repository at this point in the history
* warning if git is not installed

Signed-off-by: Kevin Su <[email protected]>

* lint

Signed-off-by: Kevin Su <[email protected]>

Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Samhita Alla <[email protected]>
  • Loading branch information
pingsutw authored and samhita-alla committed Feb 2, 2023
1 parent 3436c8e commit d25f3d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion flytekit/remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from flyteidl.admin.signal_pb2 import Signal, SignalListRequest, SignalSetRequest
from flyteidl.core import literals_pb2 as literals_pb2
from git import Repo

from flytekit import Literal
from flytekit.clients.friendly import SynchronousFlyteClient
Expand Down Expand Up @@ -127,9 +126,14 @@ def _get_git_repo_url(source_path):
Get git repo URL from remote.origin.url
"""
try:
from git import Repo

return "github.com/" + Repo(source_path).remotes.origin.url.split(".git")[0].split(":")[-1]
except ImportError:
remote_logger.warning("Could not import git. is the git executable installed?")
except Exception:
# If the file isn't in the git repo, we can't get the url from git config
remote_logger.debug(f"{source_path} is not a git repo.")
return ""


Expand Down

0 comments on commit d25f3d7

Please sign in to comment.