Skip to content

Commit

Permalink
feat: improved test infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Dec 29, 2023
1 parent 11c1e63 commit 2a9304e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 28 deletions.
58 changes: 34 additions & 24 deletions .github/workflows/build-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,47 @@ jobs:
run: pip list | grep kiara
- name: test with pytest
run: make test
- name: Coveralls
nuses: coverallsapp/github-action@v2
with:
parallel: true
flag-name: run ${{ join(matrix.*, ' - ') }}

coverage:
name: test coverage
runs-on: ubuntu-latest
steps:
- name: "Set up Python 3.10"
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: pip cache
id: pip-cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.*') }}
- uses: actions/checkout@v2
- name: install core_types plugin
run: pip install -U git+https://github.com/DHARPA-project/kiara_plugin.core_types@develop
- name: install tabular types plugin
run: pip install -U git+https://github.com/DHARPA-project/kiara_plugin.tabular@develop
- name: install kiara
run: pip install -U .[dev_testing]
- name: display installed kiara and module package versions
run: pip list | grep kiara
- name: Run coverage
run: coverage run -m pytest tests
- name: coveralls
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
format: python
allow-empty: true
parallel-finished: true
# carryforward: "run-1,run-2"
# - name: "Set up Python 3.10"
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - name: pip cache
# id: pip-cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.*') }}
# - uses: actions/checkout@v2
# - name: install core_types plugin
# run: pip install -U git+https://github.com/DHARPA-project/kiara_plugin.core_types@develop
# - name: install tabular types plugin
# run: pip install -U git+https://github.com/DHARPA-project/kiara_plugin.tabular@develop
# - name: install kiara
# run: pip install -U .[dev_testing]
# - name: display installed kiara and module package versions
# run: pip list | grep kiara
# - name: Run coverage
# run: coverage run -m pytest tests
# - name: coveralls
# uses: coverallsapp/github-action@v2
# with:
# format: python
# allow-empty: true
# - name: Upload coverage data to coveralls.io
# run: coveralls --service=github
# env:
Expand Down
1 change: 1 addition & 0 deletions src/kiara/interfaces/python_api/models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def run_tests(self):
def run_job(self) -> "ValueMap":

print(f"Running checks for job '{self._job_desc.job_alias}'...") # noqa

try:
result = self._kiara_api.run_job(operation=self._job_desc)
except Exception as e:
Expand Down
12 changes: 10 additions & 2 deletions src/kiara/registries/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def get_value(self, value: Union[uuid.UUID, ValueLink, str]) -> Value:
raise Exception(
f"Can't retrieve value for '{value}': invalid type '{type(value)}'."
)

_value_id = self._alias_resolver.resolve_alias(value)
else:
_value_id = value
Expand Down Expand Up @@ -1018,6 +1017,7 @@ def create_valuemap(
) -> ValueMap:
"""Extract a set of [Value][kiara.data.values.Value] from Python data and ValueSchemas."""
input_details = {}

for input_name, value_schema in schema.items():
input_details[input_name] = {"schema": value_schema}

Expand All @@ -1042,7 +1042,15 @@ def create_valuemap(
try:
_d = uuid.UUID(_d)
except Exception:
pass
if schema[input_name].type == "string" and not (
_d.startswith("alias:") or _d.startswith("value:")
):
pass
else:
try:
_d = self._alias_resolver.resolve_alias(_d)
except Exception:
pass

if isinstance(_d, Value):
_resolved[input_name] = _d
Expand Down
19 changes: 17 additions & 2 deletions src/kiara/utils/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def get_init_job(jobs_folder: Path) -> Union[None, JobDesc]:
if init_test_yaml.is_file():
return JobDesc.create_from_file(init_test_yaml)

init_test_yaml = jobs_folder / f"{INIT_EXAMPLE_NAME}.yml"
if init_test_yaml.is_file():
return JobDesc.create_from_file(init_test_yaml)

init_test_json = jobs_folder / f"{INIT_EXAMPLE_NAME}.json"
if init_test_json.is_file():
return JobDesc.create_from_file(init_test_json)
Expand All @@ -29,8 +33,17 @@ def list_job_descs(jobs_folder: Path):
if init_job is not None:
yield init_job

for f in sorted(jobs_folder.glob("*")):
if f.name in [f"{INIT_EXAMPLE_NAME}.yaml", f"{INIT_EXAMPLE_NAME}.json"]:
files = (
list(jobs_folder.glob("*.yaml"))
+ list(jobs_folder.glob("*.yml"))
+ list(jobs_folder.glob("*.json"))
)
for f in sorted(files):
if f.name in [
f"{INIT_EXAMPLE_NAME}.yaml",
f"{INIT_EXAMPLE_NAME}.yml",
"{INIT_EXAMPLE_NAME}.json",
]:
continue
try:
job_desc = JobDesc.create_from_file(f)
Expand Down Expand Up @@ -70,6 +83,8 @@ def get_tests_for_job(

if test_checks.is_file():
test_data: Dict[str, Any] = get_data_from_file(test_checks)
if test_data is None:
test_data = {}
else:
test_data = {}

Expand Down

0 comments on commit 2a9304e

Please sign in to comment.