Skip to content

Commit

Permalink
Preparing bug fix release v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardBruskiewich committed Apr 8, 2024
1 parent f2d8481 commit b7a5db2
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 73 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log

## 0.0.2

- fixes bugs in release 0.0.1, particularly, missing parameters at the CLI level
- Python Logging removed as an explicit parameter (logging assumed configured externally by regular Python, pyproject.toml and environmental variable conventions)

## 0.0.1

- porting of legacy SRI_Testing into OneHopTest and StandardsValidationTest TestRunners in the 2024 Translator Testing framework; this version only currently supports tests test ARA and KP components (not ARS nor UI level).
- The underlying TRAPI standard is still (via reasoner-validator 4.0.0) only to release 1.4.2;
- This release runs on the latest Biolink Model release without choking but the underlying reasoner-validator module doesn't yet do any special validation of the latest Biolink Model semantic features (in 4.1.4 and beyond)
14 changes: 7 additions & 7 deletions DEVELOPER_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Steps to properly issue a new project release:

1. Run the unit test suite to ensure that nothing fails. Iterate to fix failures (in the code or in terms of revised unit tests to reflect fresh code designs)
2. Document release changes in the **CHANGELOG.md**
3. Update the **`[Tool Poetry]version =`** field in the **pyprojects.yaml**, e.g. "0.0.1"
4. Run **`poetry update`** (preferably within **`poetry shell`**)
3. Update the **`[Tool Poetry]version =`** field in the **pyprojects.yaml**, e.g. "0.0.2"
4. Run **`poetry update`** (preferably, within a **`poetry shell`**)
5. The project pip **requirements.txt** file snapshot of dependencies should also be updated at this point (type **`$ poetry export --output requirements.txt`**, assuming that the [proper poetry export plugin is installed](https://python-poetry.org/docs/pre-commit-hooks#poetry-export)). This may facilitate module deployment within environments that prefer to use pip rather than poetry to manage their deployments.
6. Commit or pull request merge all files (including the **poetry.lock** file) to **master**
7. Add the equivalent Git **tag** to **master**. This should be the Semantic Version string from step 4 with an added 'v' prefix, i.e. "v0.0.1".
8. Push **master** to remote (if not already done with by a pull request in step 5).
6. Commit or pull request merge all files (including the **poetry.lock** file) to the local **main** branch.
7. Add the equivalent Git **tag** to **main**. This should be the Semantic Version string from step 4 with an added 'v' prefix, i.e. "v0.0.2".
8. Push **main** to remote.
9. Check if Git Actions for testing and documentation complete successfully.
10. Create the release using the same release tag, i.e. "v0.0.1".
11. Check if Git Action for package deployment is successful and check if the new version (i.e. "v0.0.1") is now visible on **[pypy.org](https://pypi.org/search/?q=OneHopTests)**
10. Create a Git package release using the same release tag, i.e. "v0.0.2".
11. Check if Git Actions for package deployment is successful and check if the new version (i.e. "v0.0.2") is now visible on **[pypy.org](https://pypi.org/search/?q=OneHopTests)**
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ options:
TRAPI version expected for knowledge graph access (default: use current default release)
--biolink_version BIOLINK_VERSION
Biolink Model version expected for knowledge graph access (default: use current default release)
--log_level {ERROR,WARNING,INFO,DEBUG}
Level of the logs.
```

### Programmatic Level Execution
Expand All @@ -107,7 +105,6 @@ test_data = {
# "trapi_version": trapi_version, # Optional[str] = None; latest community release if not given
# "biolink_version": biolink_version, # Optional[str] = None; current Biolink Toolkit default if not given
# "runner_settings": asset.test_runner_settings, # Optional[List[str]] = None
# "logger": logger, # Python Optional[logging.Logger] = None
}
results = run_standards_validation_tests(**test_data)
print(results)
Expand All @@ -133,7 +130,6 @@ test_data = {
# "trapi_version": trapi_version, # Optional[str] = None; latest community release if not given
# "biolink_version": biolink_version, # Optional[str] = None; current Biolink Toolkit default if not given
# "runner_settings": asset.test_runner_settings, # Optional[List[str]] = None
# "logger": logger, # Python Optional[logging.Logger] = None
}
results = run_one_hop_tests(**test_data)
print(results)
Expand All @@ -154,8 +150,7 @@ from graph_validation_test.utils.unit_test_templates import (
raise_object_by_subject,
raise_predicate_by_subject
)
import logging
logger = logging.getLogger(__file__)

test_data = {
# One test edge (asset)
"subject_id": "DRUGBANK:DB01592",
Expand All @@ -167,8 +162,7 @@ test_data = {
"environment": TestEnvEnum.test,
"trapi_version": "1.5.0-beta",
"biolink_version": "4.1.6",
"runner_settings": "Inferred",
"logger": logger
"runner_settings": "Inferred"
}
trapi_generators = [
# by_subject,
Expand Down Expand Up @@ -288,7 +282,7 @@ etc...

A [full change log](CHANGELOG.md) is provided documenting each release, but we summarize key release limitations here:

### Release 0.0.1
### v0.0.\* Releases

- This release only supports testing of [Translator SmartAPI Registry](https://smart-api.info/registry/translator) catalogued components which are TRAPI implementations for Translator Autonomous Relay Agent (ARA) and Knowledge Providers (KP), but _not_ direct testing of the Translator Autonomous Relay System (ARS) or Translator user interface (UI)
- This initial code release only supports testing of [Translator SmartAPI Registry](https://smart-api.info/registry/translator) catalogued components which are TRAPI implementations for Translator Autonomous Relay Agent (ARA) and Knowledge Providers (KP), but _not_ direct testing of the Translator Autonomous Relay System (ARS) or Translator user interface (UI)
- Standards validation tests currently calls release 4.0.0 of the [reasoner-validator](https://github.com/NCATSTranslator/reasoner-validator), which is currently limited to TRAPI release 1.4.2 validation (not yet the recent TRAPI 1.5.0 releases)
68 changes: 23 additions & 45 deletions graph_validation_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ def __init__(self, test_run, test, **kwargs):
"""
Constructor for a TestCaseRun.
:param test_run, owner of the use case, which should be
an instance of GraphValidationTest.
:param test, declared generator of a TestCase TRAPI query being
processed (generally, an executable function).
:param test_run: owner of the use case, which should be an instance of a subclass of GraphValidationTest.
:param test: declared generator of a TestCase TRAPI query being processed (generally, an executable function).
:param kwargs: Dict, optional extra named BiolinkValidator parameters
which may be specified for the test run.
"""
Expand All @@ -57,9 +55,6 @@ def __init__(self, test_run, test, **kwargs):
self.trapi_request: Optional[Dict] = None
self.trapi_response: Optional[Dict[str, int]] = None

def log(self, message_type: str, message: str) -> None:
self.test_run.log(message_type, message)

def get_test_asset(self) -> TestAsset:
return self.test_run.test_asset

Expand Down Expand Up @@ -124,25 +119,21 @@ def assert_test_outcome(self):
"""
if self.has_critical():
critical_msg = self.dump_critical(flat=True)
if self.test_run.logger:
self.test_run.logger.critical(critical_msg)
logger.critical(critical_msg)

elif self.has_errors():
# we now treat 'soft' errors similar to critical errors (above) but
# the validation messages will be differentiated on the user interface
err_msg = self.dump_errors(flat=True)
if self.test_run.logger:
self.test_run.logger.error(err_msg)
logger.error(err_msg)

elif self.has_warnings():
wrn_msg = self.dump_warnings(flat=True)
if self.test_run.logger:
self.test_run.logger.warning(wrn_msg)
logger.warning(wrn_msg)

elif self.has_information():
info_msg = self.dump_info(flat=True)
if self.test_run.logger:
self.test_run.logger.info(info_msg)
logger.info(info_msg)

else:
pass # do nothing... just silent pass through...
Expand Down Expand Up @@ -171,7 +162,6 @@ def __init__(
trapi_version: Optional[str] = None,
biolink_version: Optional[str] = None,
runner_settings: Optional[List[str]] = None,
test_logger: Optional[logging.Logger] = None,
**kwargs
):
"""
Expand All @@ -187,7 +177,6 @@ def __init__(
:param trapi_version: Optional[str] = None, target TRAPI version (default: current release)
:param biolink_version: Optional[str], target Biolink Model version (default: current release)
:param runner_settings: Optional[List[str]], extra string directives to the Test Runner (default: None)
:param test_logger: Optional[logging.Logger] = None, Python logger handle (default: not configured)
:param kwargs: named arguments to pass on to BiolinkValidator parent class (if and as applicable)
"""
if not component:
Expand All @@ -209,15 +198,6 @@ def __init__(
self.trapi_generators: List = trapi_generators or []

self.runner_settings = runner_settings
if test_logger:
self.logger_map = {
"info": test_logger.info,
"warning": test_logger.warning,
"error": test_logger.error,
"critical": test_logger.critical
}
else:
self.logger_map = None

self.results: Dict = dict()

Expand All @@ -233,11 +213,6 @@ def get_trapi_generators(self) -> List:
def get_runner_settings(self) -> List[str]:
return self.runner_settings.copy()

def log(self, message_type: str, message: str):
if self.logger_map is not None and \
message_type in self.logger_map.keys():
self.logger_map[message_type](message)

@classmethod
def generate_test_asset_id(cls) -> str:
cls._id += 1
Expand Down Expand Up @@ -330,7 +305,6 @@ def run_tests(
trapi_version: Optional[str] = None,
biolink_version: Optional[str] = None,
runner_settings: Optional[List[str]] = None,
test_logger: Optional[logging.Logger] = None,
**kwargs
) -> Dict[str, List]:
"""
Expand Down Expand Up @@ -363,7 +337,6 @@ def run_tests(
:param trapi_version: Optional[str] = None, target TRAPI version (default: latest public release)
:param biolink_version: Optional[str] = None, target Biolink Model version (default: Biolink toolkit release)
:param runner_settings: Optional[List[str]] = None, extra string parameters to the Test Runner
:param test_logger: Optional[logging.Logger] = None, Python logging handle
:param kwargs: Dict, optional extra named parameters to passed to TestCase TestRunner.
:return: Dict { "pks": List[<pk>], "results": List[<pk_indexed_results>] }
"""
Expand Down Expand Up @@ -404,8 +377,7 @@ def run_tests(
trapi_generators=trapi_generators,
trapi_version=trapi_version,
biolink_version=biolink_version,
runner_settings=runner_settings,
test_logger=test_logger
runner_settings=runner_settings
) for target in targets
]
#
Expand Down Expand Up @@ -503,7 +475,14 @@ def get_parameters(tool_name: str):
"--subject_id",
type=str,
required=True,
help="Statement object concept CURIE",
help="Statement subject concept CURIE",
)

parser.add_argument(
"--subject_category",
type=str,
required=True,
help="Statement subject concept Biolink category (CURIE)",
)

parser.add_argument(
Expand All @@ -517,7 +496,14 @@ def get_parameters(tool_name: str):
"--object_id",
type=str,
required=True,
help="Statement object concept CURIE ",
help="Statement object concept CURIE",
)

parser.add_argument(
"--object_category",
type=str,
required=True,
help="Statement object concept Biolink category (CURIE)",
)

parser.add_argument(
Expand All @@ -535,12 +521,4 @@ def get_parameters(tool_name: str):
default=None
)

parser.add_argument(
"--log_level",
type=str,
choices=["ERROR", "WARNING", "INFO", "DEBUG"],
help="Level of the logs (Default: WARNING)",
default="WARNING"
)

return parser.parse_args()
12 changes: 7 additions & 5 deletions one_hop_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
One Hop Tests (core tests extracted
from the legacy SRI_Testing project)
"""
from sys import stderr
from typing import Optional, Dict

from reasoner_validator.trapi import TRAPISchemaValidator
Expand All @@ -22,6 +21,8 @@
raise_object_by_subject,
raise_predicate_by_subject
)
import logging
logger = logging.getLogger(__name__)


class OneHopTestCaseRun(TestCaseRun):
Expand Down Expand Up @@ -111,16 +112,17 @@ async def run_test_case(self):
else:
trapi_version: str = response['schema_version'] \
if not self.trapi_version else self.trapi_version
print(f"run_one_hop_unit_test() using TRAPI version: '{trapi_version}'", file=stderr)
logger.info(
f"run_one_hop_unit_test() using TRAPI version: '{trapi_version}'"
)

if 'biolink_version' not in response:
self.report(code="warning.trapi.response.biolink_version.missing")
else:
biolink_version = response['biolink_version'] \
if not self.biolink_version else self.biolink_version
self.log(
message_type="info",
message=f"run_one_hop_unit_test() using Biolink Model version: '{biolink_version}'"
logger.info(
f"run_one_hop_unit_test() using Biolink Model version: '{biolink_version}'"
)

# If nothing badly wrong with the TRAPI Response to this point, then we also check
Expand Down
Loading

0 comments on commit b7a5db2

Please sign in to comment.