Skip to content

Commit

Permalink
fix(client): forgot to close the file
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui committed Jul 11, 2022
1 parent ae97c1a commit 71779a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/starwhale/base/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def list(self) -> t.List[str]:
def get_manifest_by_dir(cls, dir: Path) -> t.Dict[str, t.Any]:
_mf = dir / DEFAULT_MANIFEST_NAME
if _mf.exists():
return yaml.safe_load(_mf.open()) or {}
with open(_mf) as f:
return yaml.safe_load(f) or {}
else:
return {}
3 changes: 2 additions & 1 deletion client/starwhale/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
def ensure_file(path: t.Union[str, Path], content: str, mode: int = 0o644) -> None:
p = Path(path)
try:
_saved = p.open("r").read()
with p.open("r") as f:
_saved = f.read()
except IOError as e:
if e.errno == errno.ENOENT:
# no such file or directory
Expand Down

0 comments on commit 71779a0

Please sign in to comment.