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

Refactor registrar into multiple files #92

Merged
merged 22 commits into from
Mar 7, 2024

Conversation

stuartmcalpine
Copy link
Collaborator

@stuartmcalpine stuartmcalpine commented Jan 9, 2024

In preparation for us doing more with entries other than creating them, I've reformatted the registrar class into one for each table, e.g., dataset, execution and dataset_alias.

As before they all follow the same format with a slight tweak. e.g., datareg.Registrar.register_dataset() now becomes datareg.Registrar.dataset.create() and datareg.Registrar.execution.create() etc.

This is in preparation for new functions like datareg.Registrar.dataset.modify() or datareg.Registrar.dataset.delete() etc. Placeholders for these functions have been added.

It also tidies the code a bit (mainly in prep for the new functions) so that registrar.py didn't become very long.

Right now no internal or external functionality has changed (other than the name of the function to call for registering datasets).

Will update docs to reflect changes in another branch.

Copy link
Collaborator

@JoanneBogart JoanneBogart left a comment

Choose a reason for hiding this comment

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

I've suggested a couple specific and simple changes, but additionally we should probably think a little more about the organization. One possibility would be to make a base class - call it RegistryTable for now - which your new classes would subclass. RegistryTable would have base implementations for at least modify and delete. register is generally more complicated and different from one table to the next, so perhaps RegistryTable.register( ) would always have to be overridden by the subclass. To the extent that the different tables need, even partially, the same treatment, the base class would be a convenient place to put the common parts of the implementations.

src/dataregistry/__init__.py Outdated Show resolved Hide resolved
src/dataregistry/registrar/execution.py Outdated Show resolved Hide resolved
src/dataregistry/registrar/execution.py Outdated Show resolved Hide resolved
@stuartmcalpine
Copy link
Collaborator Author

I have updated the structure as suggested. Now there is a base table class which the execution/dataset/etc tables will inherit. The base class holds the delete and modify function as they should be universal.

The register (renamed from create) functions are in each of their own subclasses.

The only slightly dirty bit is that I have to pass the execution subclass into the dataset subclass in the Registrar class. Thats because we need to create an execution from within the dataset registration also. But I dont see a way around it.

Copy link
Collaborator

@JoanneBogart JoanneBogart left a comment

Choose a reason for hiding this comment

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

It looks good to me. I made one trivial comment.

tests/end_to_end_tests/test_end_to_end.py Outdated Show resolved Hide resolved
@stuartmcalpine stuartmcalpine merged commit 4d02abd into u/stuart/v0.4.0 Mar 7, 2024
8 checks passed
@stuartmcalpine stuartmcalpine deleted the u/stuart/reformat_registrar branch March 7, 2024 11:13
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.

2 participants