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

Moved Tabulator Subclasses & Raise Errors for Static Dialect #25

Open
wants to merge 6 commits into
base: canada-v2.9
Choose a base branch
from

Conversation

JVickery-TBS
Copy link

feat(dev): module imports, raise errors;

  • Updated imports to new module locations in canada plugin.
  • Added extra checks to static dialects to raise errors if not matching.

- Updated imports to new module locations in canada plugin.
- Added extra checks to static dialects to raise errors if not matching.
- Renamed canada script.
try:
from ckanext.canada.tabulate import (
CanadaStream as TabulatorStream,
CanadaCSVParser as TabulatorCSVParser
Copy link
Member

Choose a reason for hiding this comment

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

This is a little magical. Why not have these classes in our xloader fork if this is the only way they're used?

Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here, if xloader had an interface to let us provide stream and csvparser that would be cleaner. Importing from a specific theme from a reusable code base just feels like the wrong direction.

Copy link
Author

Choose a reason for hiding this comment

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

@wardi sorry, they were in our Xloader fork. But will be needing to use them in Goodtables and Validation

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, so if you give xloader, goodtables and validation interfaces that we could call during configuration of ckanext-canada to pass in the classes and config then we don't end up with our forks of these depending on our specific theme plugin in a fragile way.

This is another argument for building validation features into xloader to reduce the complexity, but maybe there are some users that need one without the other?

Copy link
Author

Choose a reason for hiding this comment

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

@wardi okay so just something like ITabulator and have methods like get_dialect, get_stream_class, get_parsers, and get_encoding??

Would all three plugins (goodtables, Xloader, Validation) need to have this plugin implementation in their codebase? So just copy the ITabulator class to each one?

Copy link
Member

Choose a reason for hiding this comment

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

It could be something as simple as a function you can call to change the default configuration/register the new classes required in goodtables, xloader and validation. Doesn't have to be the same on all three.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Or am I reaaaaly beneath monkey patching Tabulator classes in our Canada plugin hahaha

Copy link
Member

Choose a reason for hiding this comment

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

that's an option, and one I've reached for in the past. Not a great option because monkey patching is super confusing for the person debugging a few years from now, but if it's extremely painful to implement an interface to allow validation to be configured I could understand. Just make sure to use lots of FIXME comments in ckanext-canada explaining why it was done that way :-/

- Only enforce dialect if the stream has guessed any.
- Created a tabulator interface.
- Move everything into canada plugin.
- Moved code to canada plugin.
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