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

DAS-NONE: Random small fixes. #38

Merged
merged 14 commits into from
Dec 12, 2024
Merged

DAS-NONE: Random small fixes. #38

merged 14 commits into from
Dec 12, 2024

Conversation

flamingbear
Copy link
Member

@flamingbear flamingbear commented Dec 10, 2024

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.

❯ ./bin/build-image && ./bin/build-test &&  ./bin/run-test

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

  • [NA] Jira ticket acceptance criteria met.
  • CHANGELOG.md updated to include high level summary of PR changes.
  • [NO] docker/service_version.txt updated if publishing a release.
  • Tests added/updated and passing.
  • [NA] Documentation updated (if needed).

@flamingbear
Copy link
Member Author

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.

Copy link
Member Author

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.

@@ -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
Copy link
Member Author

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()
Copy link
Member Author

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(
'''
"""
Copy link
Member Author

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
)
Copy link
Member Author

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.

@@ -20,28 +20,19 @@ STATUS=0

export HDF5_DISABLE_VERSION_CHECK=1
Copy link
Member Author

@flamingbear flamingbear Dec 10, 2024

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...

Copy link
Member

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)

@flamingbear flamingbear marked this pull request as ready for review December 11, 2024 00:13
@@ -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)?'
Copy link

@vutrannasa vutrannasa Dec 11, 2024

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?

Copy link
Member Author

@flamingbear flamingbear Dec 11, 2024

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)

Copy link
Member

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.

echo "ERROR: unittest generated errors"
fi
# Exit status used to report back to caller
STATUS=0

Choose a reason for hiding this comment

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

Copy link
Member Author

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

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.

Copy link
Member Author

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.

Copy link
Member

@owenlittlejohns owenlittlejohns left a 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)?'
Copy link
Member

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.

@@ -20,28 +20,19 @@ STATUS=0

export HDF5_DISABLE_VERSION_CHECK=1
Copy link
Member

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)

Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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']
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@owenlittlejohns owenlittlejohns Dec 11, 2024

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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

@flamingbear flamingbear merged commit 2f47607 into main Dec 12, 2024
7 checks passed
@flamingbear flamingbear deleted the mhs/DAS-NONE/miscellany branch December 12, 2024 16: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.

3 participants