Skip to content

Commit

Permalink
handle git fatal error on non-git projects (#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
avan-sh authored Apr 13, 2022
1 parent 30f4ccd commit b3c78e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 6 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

## Major features and improvements

* Added more detail to YAML ParserError error message
* Added more detail to YAML ParserError error message.

## Bug fixes and other changes
* Removed fatal error from being logged when a Kedro session is created in a directory without git.


## Upcoming deprecations for Kedro 0.19.0

Expand Down Expand Up @@ -55,9 +57,9 @@ main(
| Type | Description | Location |
| ------------------------- | ------------------------------------------------------------- | -------------------------------- |
| `pandas.XMLDataSet` | Read XML into Pandas DataFrame. Write Pandas DataFrame to XML | `kedro.extras.datasets.pandas` |
| `networkx.GraphMLDataSet` | Work with NetworkX using GraphML files | `kedro.extras.datasets.networkx` |
| `networkx.GMLDataSet` | Work with NetworkX using Graph Modelling Language files | `kedro.extras.datasets.networkx` |
| `redis.PickleDataSet` | loads/saves data from/to a Redis database | `kedro.extras.datasets.redis` |
| `networkx.GraphMLDataSet` | Work with NetworkX using GraphML files | `kedro.extras.datasets.networkx` |
| `networkx.GMLDataSet` | Work with NetworkX using Graph Modelling Language files | `kedro.extras.datasets.networkx` |
| `redis.PickleDataSet` | loads/saves data from/to a Redis database | `kedro.extras.datasets.redis` |

* Added `partitionBy` support and exposed `save_args` for `SparkHiveDataSet`.
* Exposed `open_args_save` in `fs_args` for `pandas.ParquetDataSet`.
Expand Down
18 changes: 11 additions & 7 deletions kedro/framework/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ def _deactivate_session() -> None:

def _describe_git(project_path: Path) -> Dict[str, Dict[str, Any]]:
project_path = str(project_path)

try:
res = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"], cwd=project_path
["git", "rev-parse", "--short", "HEAD"],
cwd=project_path,
stderr=subprocess.STDOUT,
)
git_data = {"commit_sha": res.decode().strip()} # type: Dict[str, Any]
git_status_res = subprocess.check_output(
["git", "status", "--short"],
cwd=project_path,
stderr=subprocess.STDOUT,
)
git_data["dirty"] = bool(git_status_res.decode().strip())

# `subprocess.check_output()` raises `NotADirectoryError` on Windows
except (subprocess.CalledProcessError, FileNotFoundError, NotADirectoryError):
logging.getLogger(__name__).warning("Unable to git describe %s", project_path)
return {}

git_data = {"commit_sha": res.decode().strip()} # type: Dict[str, Any]

res = subprocess.check_output(["git", "status", "--short"], cwd=project_path)
git_data["dirty"] = bool(res.decode().strip())

return {"git": git_data}


Expand Down

0 comments on commit b3c78e5

Please sign in to comment.