OSW-1617: Fix table relationships in CDB schema#104
Open
Conversation
11d41a4 to
4255b35
Compare
tests/validate_schema_migrations.py
Outdated
|
|
||
| def _load_metadata(yaml_path: Path) -> sa.MetaData: | ||
| """Build SQLAlchemy metadata from a Felis YAML schema.""" | ||
| yaml_data = yaml.safe_load(yaml_path.read_text()) |
Contributor
There was a problem hiding this comment.
I would recommend to use instead Schema.from_uri(path, context={"id_generation": True}) here and any other places where the schema is loaded into Felis.
tests/compare_yaml_schemas.py
Outdated
| b_path = args.schema_b.expanduser() | ||
| if not a_path.is_file() or not b_path.is_file(): | ||
| print(f"Both inputs must be files. Got: {a_path} and {b_path}") | ||
| return 1 |
Contributor
There was a problem hiding this comment.
Best to make this a variable which indicates what the return value is supposed to mean.
tests/compare_yaml_schemas.py
Outdated
| print("Differences found:") | ||
| for line in diffs: | ||
| print(f"- {line}") | ||
| return 2 |
Contributor
There was a problem hiding this comment.
Also make this a variable.
7e690b3 to
cd57b20
Compare
cd57b20 to
97a9a78
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These migrations correspond to the schema changes in sdm_schemas in the tickets/OSW-1617 branch. They are designed to unify all of the instruments with a common schema.
This PR also includes some test scripts and other scripting improvements. The script
validate_schema_migrations.pyruns a few checks for a new migration, verifying that the completed migration matches the YAML file that generated it and that the downgrade feature correctly reverses the effect of the upgrade.A review of these migration scripts on a locally generated database show that the migrations apply correctly and work as expected. The resulting schemas are the same across all instruments.