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

Generalise country specific code using abstract base class #84

Closed
andrewphilipsmith opened this issue Apr 30, 2024 · 2 comments
Closed
Assignees

Comments

@andrewphilipsmith
Copy link
Collaborator

Following a discussion with @yongrenjie @sgreenbury and @andrewphilipsmith.

We came up with this approximate pattern as a way to generalise some of the country-specific code:

class generic_country(ABC):

    def get_source_table(self):
        @asset()
        def inner():
            return self._get_source_table()

        return inner
    
    # Must be implemented by the child class
    def _get_source_table(self):
        pass

class Redland(generic_country):

    def _get_source_table(self):
        return "Redland"

if __name__ == "__main__":
    redland = Redland()
    
    defs = Definitions(
        assets=[redland.get_source_table()]
    )
@andrewphilipsmith
Copy link
Collaborator Author

@sgreenbury will attempt this with Northern Ireland (#26).

@sgreenbury
Copy link
Collaborator

@andrewphilipsmith: Initial version of this now implemented in #98 and #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done:
Development

No branches or pull requests

2 participants