Skip to content

Commit

Permalink
ensure workdir is always an absolute path (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeifer authored Nov 8, 2023
1 parent de9b29e commit 397f045
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Ensure `workdir` is an absolute path
([#54](https://github.com/stac-utils/stac-task/pull/51)).
- When a `workdir` is set for a `Task` the `workdir` will no longer be removed
by default [#51](https://github.com/stac-utils/stac-task/pull/51)). That is,
by default ([#51](https://github.com/stac-utils/stac-task/pull/51)). That is,
the `save_workdir` argument to `Task` constructor now defaults to `None`, and
if left as `None` the default behavior is now conditional on whether or not a
`workdir` is specified.
Expand Down
2 changes: 1 addition & 1 deletion stactask/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
# if we are using a temp workdir we want to rm by default
self._save_workdir = save_workdir if save_workdir is not None else False
else:
self._workdir = Path(workdir)
self._workdir = Path(workdir).absolute()
makedirs(self._workdir, exist_ok=True)
# if a workdir was specified we don't want to rm by default
self._save_workdir = save_workdir if save_workdir is not None else True
Expand Down
2 changes: 2 additions & 0 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_tmp_workdir(items: Dict[str, Any], save_workdir: Optional[bool]) -> Non
assert nothing_task._save_workdir is expected
workdir = nothing_task._workdir
assert workdir.parts[-1].startswith("tmp")
assert workdir.is_absolute() is True
assert workdir.is_dir() is True
del nothing_task
assert workdir.is_dir() is expected
Expand All @@ -77,6 +78,7 @@ def test_workdir(
assert t._save_workdir is expected
workdir = t._workdir
assert workdir.parts[-1] == "test_task"
assert workdir.is_absolute() is True
assert workdir.is_dir() is True
del t
assert workdir.is_dir() is expected
Expand Down

0 comments on commit 397f045

Please sign in to comment.