Skip to content

Commit

Permalink
fix(cli): expand user on cache directory (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
fschuch authored Dec 7, 2023
1 parent 08a7fef commit a50ddfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobbergate-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ This file keeps track of all notable changes to jobbergate-cli

## Unreleased

- Fixed the setting `CACHE_DIR` to expand the user home directory, allowing more flexibility on the path [ASP-4053]

## 4.2.0a3 -- 2023-11-30

- Added support for on-site job submissions using the `sbatch` command [ASP-4238]

## 4.2.0a2 -- 2023-11-29

## 4.2.0a1 -- 2023-11-13

- Patched create-job-script command on submit mode when parameter file is provided
Expand Down
1 change: 1 addition & 0 deletions jobbergate-cli/jobbergate_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def compute_extra_settings(cls, values):
"""
Compute settings values that are based on other settings values.
"""
values["JOBBERGATE_CACHE_DIR"] = Path(values["JOBBERGATE_CACHE_DIR"]).expanduser().resolve()
cache_dir = values["JOBBERGATE_CACHE_DIR"]
cache_dir.mkdir(exist_ok=True, parents=True)

Expand Down
7 changes: 7 additions & 0 deletions jobbergate-cli/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

import pydantic
import pytest
Expand Down Expand Up @@ -29,3 +30,9 @@ def test_Validation_error__when_parameter_is_missing():
finally:
if original_value is not None:
os.environ["OIDC_DOMAIN"] = original_value


def test_cache_dir__expands_user_and_resolves():
settings = Settings(JOBBERGATE_CACHE_DIR="~/.jobbergate-cli-prod")
assert settings.JOBBERGATE_CACHE_DIR == Path.home() / ".jobbergate-cli-prod"
assert settings.JOBBERGATE_CACHE_DIR.is_absolute()

0 comments on commit a50ddfe

Please sign in to comment.