Skip to content

Commit

Permalink
adding __fspath__ method instead of __str__ in _ConfigWrapper and fin…
Browse files Browse the repository at this point in the history
…ally fixing the hanging issue
  • Loading branch information
mo-dkrz committed May 13, 2024
1 parent d0f4873 commit 760089b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ export MOCK_SLURM := /tmp/mock_slurm_$$RANDOM
export EVALUATION_SYSTEM_PLUGINS := $(EVALUATION_SYSTEM_PLUGINS):$(PWD)/src/evaluation_system/tests/mocks,dummy:$(PWD)/src/evaluation_system/tests/mocks,dummyfolder:/tmp/animator,animator
export EVALUATION_SYSTEM_CONFIG_FILE := $(PWD)/compose/local-eval-system.conf
export EVALUATION_SYSTEM_DRS_CONFIG_FILE := $(PWD)/compose/drs_config.toml
PYTHON := $(shell which python)
PYTHON3 := $(shell which python3)
all: install test_coverage

.PHONY: docs
install:
python -m pip install .[test]
python3 -m pip install .[test]

test:
python -m pytest -vv --nbval --current-env $(PWD)/src/evaluation_system/tests
python3 -m pytest -vv --nbval --current-env $(PWD)/src/evaluation_system/tests

test_coverage:
python -m pytest -vv \
python3 -m pytest -vv \
--nbval --current-env --cov=$(PWD)/src --cov-report=html:coverage_report \
--junitxml report.xml --current-env --cov-report xml \
$(PWD)/src/evaluation_system/tests
python -m coverage report
python3 -m coverage report

prepdocs:
rm -rf /tmp/animator
python -m pip install -e .[docs]
python3 -m pip install -e .[docs]
git clone --recursive https://gitlab.dkrz.de/freva/plugins4freva/animator.git /tmp/animator
mkdir -p /tmp/animator/plugin_env/bin
ln -s $(PYTHON) /tmp/animator/plugin_env/bin/python
python -m ipykernel install --user --name freva \
ln -s $(PYTHON3) /tmp/animator/plugin_env/bin/python
python3 -m ipykernel install --user --name freva \
--env EVALUATION_SYSTEM_CONFIG_FILE $(EVALUATION_SYSTEM_CONFIG_FILE) \
--env EVALUATION_SYSTEM_PLUGINS $(EVALUATION_SYSTEM_PLUGINS)
python -m bash_kernel.install
python3 -m bash_kernel.install
make dummy-data
compose/animator_plugin_run.sh

Expand All @@ -42,8 +42,8 @@ docs:

dummy-data:
compose/dummy_plugin_runs.sh
python compose/dummy_user_data.py
python compose/solr/ingest_dummy_data.py
python3 compose/dummy_user_data.py
python3 compose/solr/ingest_dummy_data.py

lint:
mypy --install-types --non-interactive
Expand Down
8 changes: 4 additions & 4 deletions src/evaluation_system/misc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_level(self, level: Union[int, str]) -> None:
logger.addHandler(logger_stream_handle)


class _ConfigWrapper(str):
class _ConfigWrapper:
"""Convenience class that helps to dynamically set the location of the
evaluation system config file."""

Expand All @@ -55,8 +55,8 @@ def __init__(
):
self.default_file = default_file

def __str__(self) -> str:
return os.environ.get(self._env, self.default_file)

def __repr__(self) -> str:
return self.__str__()

def __fspath__(self) -> str:
return os.environ.get(self._env, self.default_file)
20 changes: 10 additions & 10 deletions src/evaluation_system/tests/plugin_command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ def test_plugin_status(dummy_env, caplog) -> None:

import freva

# res = freva.run_plugin("dummyplugin", the_number=2, other=-5, batchmode=True)
# # with pytest.raises(ValueError):
# # res.wait()
# # assert res.status == "running"
# res.kill()
# time.sleep(0.5)
# assert res.status == "broken"
# res.kill()
res = freva.run_plugin("dummyplugin", the_number=2, other=-1, batchmode=False)
res = freva.run_plugin("dummyplugin", the_number=2, other=-5, batchmode=True)
with pytest.raises(ValueError):
res.wait(2)
assert res.status == "running"
res.kill()
time.sleep(0.5)
assert res.status == "broken"
res.kill()
res = freva.run_plugin("dummyplugin", the_number=2, other=-1, batchmode=True)
res.wait()
assert res.status == "finished"
# assert isinstance(res.batch_id, int)
assert isinstance(res.batch_id, int)


def test_plugin_output(dummy_history) -> None:
Expand Down

0 comments on commit 760089b

Please sign in to comment.