-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for GSF v3.09 #125
Conversation
lmarsden
commented
Feb 23, 2021
•
edited
Loading
edited
- Introduces a pattern for supporting future new versions of GSF.
- Default supported version in the top level gsfpy namespace remains as v3.08 for backwards compatibility.
- Provides option for changing default version in top level namespace via a DEFAULT_GSF_VERSION environment variable.
- Provides version-specific gsfpy3_08 and gsfpy3_09 namespaces as alternative to defining the default GSF version via environment.
* Also introduces a pattern for supporting future new versions of GSF. * Default supported version in the top level gsfpy namespace remains as v3.08 for backwards compatibility. * Provides option for changing default version in top level namespace via a DEFAULT_GSF_VERSION environment variable. * Provides version-specific gsfpy3_08 and gsfpy3_09 namespaces as alternative to defining the default GSF version at the top level.
* Note that the top-level gsfpy namespace is not included in coverage reporting as it simply acts as a switch between gsfpy3_08 and gsfpy3_09.
* For improved backward compatibility it must be possible to do imports of the form 'from gsfpy.enums import ...'
* In order that imports of the form 'from gsfpy.gsfRecords import ...' can be used with the version-specific implementations of the package it is necessary to mirror those implementations from the top level gsfpy namespace. This is now done in a generic way using dynamic import, so that future versions of GSF will also be supported without any code changes in the top-level gsfpy package being necessary.
tests/gsfpy3_08/conftest.py
Outdated
# GSF_03_08_DATAFILE = GsfDatafile( | ||
# GsfVersion.V03_08, | ||
# Path(__file__).parent.parent | ||
# / "test_data" | ||
# / "0059_20181102_212138_EX1811_MB_EM302.gsf.mb121", | ||
# num_beams=432, | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - the GSF 3.08 tests now use only GSF_03_08_DATAFILE test data
tests/gsfpy3_08/conftest.py
Outdated
# @pytest.fixture | ||
# def gsf_test_data_03_08(tmp_path): | ||
# yield from _setup_gsf_test_data(GSF_03_08_DATAFILE, tmp_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented fixtures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
tests/gsfpy3_08/conftest.py
Outdated
[ | ||
gsf_test_data_03_06, | ||
gsf_test_data_03_07, | ||
# gsf_test_data_03_08, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - GSF 3.08 tests now use only GSF 3.08 test data
tests/gsfpy3_08/conftest.py
Outdated
params=[ | ||
GSF_03_06_DATAFILE, | ||
GSF_03_07_DATAFILE, | ||
# GSF_03_08_DATAFILE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
poetry run pytest --ignore-glob=tests/gsfpy3_08/* --ignore-glob=tests/gsfpy3_09/* --ignore-glob=tests/gsfpy/test_gsffile_with_*.py --verbose --capture=no | ||
poetry run pytest --ignore-glob=tests/gsfpy3_08/* --ignore-glob=tests/gsfpy3_09/* --ignore-glob=tests/gsfpy/test_gsffile.py --verbose --capture=no | ||
poetry run pytest tests/gsfpy3_08/test_libgsf_load_valid.py --verbose --capture=no | ||
poetry run pytest tests/gsfpy3_08/test_libgsf_load_invalid.py --verbose --capture=no | ||
poetry run pytest tests/gsfpy3_08/test_libgsf_load_default.py --verbose --capture=no | ||
poetry run pytest --ignore-glob=tests/gsfpy3_08/test_libgsf_load_*.py --ignore-glob=tests/gsfpy3_09/* --verbose --capture=no --cov=gsfpy3_08 --cov-fail-under=95 --cov-config=tox.ini | ||
poetry run pytest tests/gsfpy3_09/test_libgsf_load_valid.py --verbose --capture=no | ||
poetry run pytest tests/gsfpy3_09/test_libgsf_load_invalid.py --verbose --capture=no | ||
poetry run pytest tests/gsfpy3_09/test_libgsf_load_default.py --verbose --capture=no | ||
poetry run pytest --ignore-glob=tests/gsfpy3_09/test_libgsf_load_*.py --ignore-glob=tests/gsfpy3_08/* --verbose --capture=no --cov=gsfpy3_09 --cov-fail-under=95 --cov-config=tox.ini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason these are run individually rather than just pointing pytest at the tests folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a reason! Once a module is loaded in python it is almost impossible to unload it. Therefore for tests which are checking the gsfpy behaviour of loading the correct version-specific namespace based on the DEFAULT_GSF_VERSION env variable, or loading custom versions of the libgsf shared object libraries, it is necessary to execute these in their own dedicated pytest runs.
README.md
Outdated
pip install git+ssh://[email protected]/UKHO/gsfpy3_08.git@master | ||
``` | ||
#### From GitHub (HTTPS) | ||
```shell script | ||
pip install git+https://github.com/UKHO/gsfpy.git@master | ||
pip install git+https://github.com/UKHO/gsfpy3_08.git@master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these path's correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
README.md
Outdated
@@ -174,7 +181,7 @@ More recent versions of these documents can be downloaded from the | |||
By default Poetry will create it's own virtual environment using your system's Python. [This feature can be disabled.](https://python-poetry.org/docs/faq/#i-dont-want-poetry-to-manage-my-virtual-environments-can-i-disable-it) | |||
|
|||
```shell script | |||
git clone [email protected]:UKHO/gsfpy.git | |||
git clone [email protected]:UKHO/gsfpy3_08.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
README.md
Outdated
@@ -184,7 +191,7 @@ poetry install | |||
A good choice if you want to run a version of Python different than available through your system's package manager | |||
|
|||
```shell script | |||
git clone [email protected]:UKHO/gsfpy.git | |||
git clone [email protected]:UKHO/gsfpy3_08.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
README.md
Outdated
@@ -216,7 +223,7 @@ calling gsfpy to assess these risks and mitigate where deemed necessary. | |||
GSF data processed using gsfpy should be sourced from reliable providers | |||
and checked for integrity where possible. | |||
|
|||
Please also refer to the LICENSE file for the terms of use of gsfpy. | |||
Please also refer to the LICENSE file for the terms of use of gsfpy3_08. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
gsfpy/__init__.py
Outdated
count = gsfGetNumberRecords(self._handle, desired_record) | ||
_handle_failure(count) | ||
return count | ||
def mirror_default_gsf_version_submodule(_globals: dict, submodule_name: str = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename the _globals to globals_dict. Leading underscore is misleading as it used for privacy etc. In this case I believe the _ is used to avoid clashing with the globals command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, yes the original name was used to avoid the clash with globals(). Agree that globals_dict is a better alternative.