Skip to content
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

Merged
merged 16 commits into from
Mar 3, 2021
Merged

Add support for GSF v3.09 #125

merged 16 commits into from
Mar 3, 2021

Conversation

lmarsden
Copy link
Contributor

@lmarsden lmarsden commented Feb 23, 2021

  • 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.
@lmarsden lmarsden marked this pull request as ready for review February 26, 2021 13:34
@lmarsden lmarsden requested a review from eganjs February 26, 2021 13:34
@lmarsden lmarsden linked an issue Feb 26, 2021 that may be closed by this pull request
Comment on lines 39 to 45
# 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,
# )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented data?

Copy link
Contributor Author

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

Comment on lines 68 to 70
# @pytest.fixture
# def gsf_test_data_03_08(tmp_path):
# yield from _setup_gsf_test_data(GSF_03_08_DATAFILE, tmp_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented fixtures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

[
gsf_test_data_03_06,
gsf_test_data_03_07,
# gsf_test_data_03_08,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be uncommented?

Copy link
Contributor Author

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

params=[
GSF_03_06_DATAFILE,
GSF_03_07_DATAFILE,
# GSF_03_08_DATAFILE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +71 to +80
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

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?

Copy link
Contributor Author

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
Comment on lines 42 to 46
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

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?

Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

count = gsfGetNumberRecords(self._handle, desired_record)
_handle_failure(count)
return count
def mirror_default_gsf_version_submodule(_globals: dict, submodule_name: str = None):

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?

Copy link
Contributor Author

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.

Base automatically changed from master to main March 1, 2021 13:52
eganjs
eganjs previously approved these changes Mar 2, 2021
andyphelps
andyphelps previously approved these changes Mar 3, 2021
@lmarsden lmarsden dismissed stale reviews from andyphelps and eganjs via 38e96ab March 3, 2021 08:58
@lmarsden lmarsden requested a review from andyphelps March 3, 2021 08:59
@lmarsden lmarsden merged commit 5ec4996 into main Mar 3, 2021
@lmarsden lmarsden deleted the support_gsf_3_09 branch August 16, 2021 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for GSF 3.09
3 participants