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

FIX: Invert default schema URLs #971

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Conversation

mferrera
Copy link
Collaborator

@mferrera mferrera commented Jan 14, 2025

Resolves #968

@mferrera mferrera force-pushed the invert-schema-url branch 2 times, most recently from 1751d3e to 762e5ac Compare January 14, 2025 10:25
@mferrera mferrera self-assigned this Jan 14, 2025
@mferrera mferrera force-pushed the invert-schema-url branch 4 times, most recently from 5b21277 to ad968ea Compare January 14, 2025 11:28
@mferrera mferrera marked this pull request as ready for review January 14, 2025 11:31
@mferrera mferrera force-pushed the invert-schema-url branch 5 times, most recently from 0a3a6f0 to c939dc6 Compare January 14, 2025 12:11
Comment on lines +46 to +47
if [[ "${{ github.event.pull_request.base.ref }}" == "staging" ]]; then
pytest -n auto -v --cov --cov-report term-missing --prod
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both pytest and update-schemas take a --prod flag now. Both ensure the DEV_SCHEMAS environment variable is unset. This causes the default case to happen: schemas and metadata are produced with the production url.

Comment on lines -63 to +64
"pytest",
"pytest-xdist",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sort + not sure why this dependency was never added to parallelize tests

Comment on lines +141 to +143
if os.environ.get("DEV_SCHEMA", False):
return DEV_URL
return PROD_URL
Copy link
Collaborator Author

@mferrera mferrera Jan 14, 2025

Choose a reason for hiding this comment

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

We won't be able to produce metadata with the $schema = radix dev in Komodo bleeding without exploring some other option. I guess this is OK but not ideal. Could check for KOMODO_BLEEDING explicitly, but I don't really like that

Comment on lines +55 to +58
def pytest_addoption(parser):
parser.addoption(
"--prod", action="store_true", help="Use schemas/metadata with production URLs."
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes pytest aware of our custom pytest --prod command, configured below. But also set at the top of this file because pytest, and some tests, do funky things with environment variables. Since the models in dataio look for this environment variable it is safest to ensure it's set before they are imported, but are still set by the pytest config anyway

Comment on lines +237 to +238
# Ensures URLs will differ based on above
import fmu.dataio._models as models
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lazy import to ensure the models receive the DEV_SCHEMA env var we want them to

Copy link
Contributor

@slangeveld slangeveld left a comment

Choose a reason for hiding this comment

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

👍 I like the new 🚨

@mferrera mferrera merged commit da21732 into equinor:main Jan 15, 2025
16 checks passed
@mferrera mferrera deleted the invert-schema-url branch January 15, 2025 05:43
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.

Invert default schema URLs
2 participants