-
Notifications
You must be signed in to change notification settings - Fork 5
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
DAS-NONE: Random small fixes. #38
Conversation
No functional differences.
Removes jupyter-black dependency.
I didn't know, but the message from the caught exception is not added directly to the raised exception.
This tweak is going wild.
7397a2f
to
920ab4d
Compare
I verified everything and I'm about to work from here to fix the rgb[a] images from DAS-2276 and I will release the changes together. |
docs/HyBIG-Example-Usage.ipynb
Outdated
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.
Just changed 2 comments for line length.
harmony_service/adapter.py
Outdated
@@ -145,7 +145,7 @@ def process_item(self, item: Item, source: HarmonySource) -> Item: | |||
|
|||
except Exception as exception: | |||
self.logger.exception(exception) | |||
raise HyBIGServiceError from exception | |||
raise HyBIGServiceError(str(exception)) from exception |
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.
This actually is a change before we logged the correct exception and raised a new one from the old, but the workflow-ui didn't show any information about it.
HyBIGServiceError, | ||
('You are forbidden to download.'), | ||
): | ||
hybig.invoke() |
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.
This tests that an error raised in the harmony-service-lib is raised as a HyBIGServiceError and has the correct information attached. This is displayed in the workflow-ui
@@ -54,7 +54,7 @@ | |||
) | |||
|
|||
WKT_EPSG_6050 = dedent( | |||
''' | |||
""" |
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.
what animal used three single quotes? 🪞
self.assertEqual(actual_scale_extent, expected_scale_extent) | ||
assert expected_scale_extent == pytest.approx( | ||
actual_scale_extent, rel=1e-12 | ||
) |
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.
This showed up with a 14th decimal place difference between python versions.
tests/run_tests.sh
Outdated
@@ -20,28 +20,19 @@ STATUS=0 | |||
|
|||
export HDF5_DISABLE_VERSION_CHECK=1 |
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.
This line doesn't seem necessary. I wonder if it's here from another project...
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.
Yeah, this is some straight-up cargo cult stuff from some older version of this script which has been copied and pasted from project to project. Agree with cutting it. (One day this file will be a glorious one liner that just becomes part of the CI/CD directly)
@@ -21,7 +21,7 @@ def get_tiled_file_extension(file_name: Path) -> str: | |||
generate the correct one to pass in. | |||
|
|||
""" | |||
ext_pattern = r"(\.r\d+c\d+)?\.(png|jpg|pgw|jgw|txt)(.aux.xml)?" | |||
ext_pattern = r'(\.r\d+c\d+)?\.(png|jpg|pgw|jgw|txt)(.aux.xml)?' |
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.
Why change double quote to single quote?
Consistently?
Coding standards?
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.
Both of those things. I don't have a preference, but I couldn't convince Owen to go to Black style formatting with the double quotes. I'm not actually sure how all of these became double quotes in the past because we did have some style checks that I thought would have caught them. The new ruff-formatting added and used by pre-commit.ci, runs on all files, and found all of the places where I just accidentally left double quotes in.
So tl;dr Yes, consistency and coding standards.
ok, I looked, before we used black-jupyter with "skip-string-normalization" which just leaves strings however you put them in, and doesn't change them. the pyproject.toml specifies "single" for quote style to force you to choose one. (consistency)
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.
I couldn't convince Owen to go to Black style formatting with the double quotes.
😅
before we used black-jupyter with "skip-string-normalization" which just leaves strings however you put them in
Yup, this.
Why change double quote to single quote?
Consistently?
Coding standards?
I think somewhere in PEP008 there's a sentence about whether to use single or double quotes. The sentiment is basically: it doesn't really matter which, but pick one and use it consistently.
Just simplify.
tests/run_tests.sh
Outdated
echo "ERROR: unittest generated errors" | ||
fi | ||
# Exit status used to report back to caller | ||
STATUS=0 |
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.
Looking at the raw file
https://github.com/nasa/harmony-browse-image-generator/blob/8bf518b4a1af610f408b13fcb7d3e9356e44a01b/tests/run_tests.sh
Double declaration of STATUS=0 on Line 19 Line 25
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.
pytest --cov=hybig --cov=harmony_service \ | ||
--cov-report=html:reports/coverage \ | ||
--cov-report term \ | ||
--junitxml=reports/test-reports/test-results-"$(date +'%Y%m%d%H%M%S')".xml || STATUS=1 |
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.
Not sure if STATUS=1 is set from code 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.
This is where we set it when the test fails so that the exit code is non-zero on failures.
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.
Looks good to me.
I mentioned in a comment lower down, but I think bumping the Python version of the service is possibly worth a release all of it's own. I know that increases overhead a little bit (with testing, etc), so I'll let you make that call.
@@ -21,7 +21,7 @@ def get_tiled_file_extension(file_name: Path) -> str: | |||
generate the correct one to pass in. | |||
|
|||
""" | |||
ext_pattern = r"(\.r\d+c\d+)?\.(png|jpg|pgw|jgw|txt)(.aux.xml)?" | |||
ext_pattern = r'(\.r\d+c\d+)?\.(png|jpg|pgw|jgw|txt)(.aux.xml)?' |
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.
I couldn't convince Owen to go to Black style formatting with the double quotes.
😅
before we used black-jupyter with "skip-string-normalization" which just leaves strings however you put them in
Yup, this.
Why change double quote to single quote?
Consistently?
Coding standards?
I think somewhere in PEP008 there's a sentence about whether to use single or double quotes. The sentiment is basically: it doesn't really matter which, but pick one and use it consistently.
tests/run_tests.sh
Outdated
@@ -20,28 +20,19 @@ STATUS=0 | |||
|
|||
export HDF5_DISABLE_VERSION_CHECK=1 |
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.
Yeah, this is some straight-up cargo cult stuff from some older version of this script which has been copied and pasted from project to project. Agree with cutting it. (One day this file will be a glorious one liner that just becomes part of the CI/CD directly)
tests/test_code_format.py
Outdated
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.
👍
@@ -15,7 +15,7 @@ | |||
# and updates the entrypoint of the new service container | |||
# | |||
############################################################################### | |||
FROM python:3.11 | |||
FROM python:3.12 |
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.
Nice - I'm tempted to suggest releasing a version of HyBIG with just this change of Python version. Feels like it could be a fair candidate for a patch version.
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.
I really don't want to because it's a bunch of overhead for something that will be replaced as soon as I finish all that overhead. The next release will change functionality significantly and require updated regression-tests.
I could release it and not deploy it, but that also seems kind of dumb in that you've just created another version that is lying around.
I just did this in a separate PR to make it easier for someone to review and test. Since this does run against the existing regressions.
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.
Fair enough. Given there isn't a dedicated ticket specifically for this clean up, I can buy that.
@@ -10,7 +10,7 @@ jobs: | |||
strategy: | |||
fail-fast: false | |||
matrix: | |||
python-version: ['3.10', '3.11'] | |||
python-version: ['3.10', '3.11', '3.12'] |
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.
Nice!
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.
Out of scope for this PR - but if you are cleaning things up, you could tweak the process_item
method to use a context manager with tempfile.TemporaryDirectory
(like you do in the SMAP L2 Gridder) instead of the mkdtemp
and a finally
for clean-up. Both work, and both are fine, but I think you convinced me the context manager is marginally simpler.
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.
I like that. Maybe in a follow-on PR.
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.
Ugh, mixing pytest fixtures and unittest patches.
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.
wow that was a dumb 🐰 🕳️ 4fcded7
Description
No functional differences.
Service python version updated to 3.12.
Updates the test matrix to include python 3.12.
Replaces OS with Path in adapter.py.
Updates the pre-commit-config to remove dependency on black-jupyter.
Runs pre-commit on all files and commits those changes.
Simplifies the test scripts with pytest and adds a report directory for artifacts.
Jira Issue ID
DAS-None
Local Test Steps
Pull this branch build and run tests.
Verify the code still runs the current regressions by deploying the new hybig image to your local Harmony-In-A-Box and run the hybig regression tests.
You can additionally verify that the changes to the github actions creates a correct artifact containing the coverage and test report. https://github.com/nasa/harmony-browse-image-generator/actions/runs/12266465971?pr=38
PR Acceptance Checklist
CHANGELOG.md
updated to include high level summary of PR changes.docker/service_version.txt
updated if publishing a release.