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

Use frictionless framework v5 #69

Merged
merged 62 commits into from
Oct 27, 2022
Merged

Conversation

aivuk
Copy link
Contributor

@aivuk aivuk commented Sep 22, 2022

Update the extension to use Frictionless Framework version 5. Change the validate function from Goodtables to the Frictionless equivalent.

TODO:

  • Update the Report component to display the validation results using the new React component.
  • Add more documentation in how to pass the option parameters to the validate function. With goodtables you could pass skip_rows and headers options that are not supported by the current validate.
  • Add tests for the new validate options

@aivuk aivuk requested a review from amercader September 22, 2022 09:25
@amercader
Copy link
Member

@aivuk this PR should be against dev-v2 right?

@aivuk aivuk changed the base branch from master to dev-v2 September 22, 2022 12:11
@aivuk
Copy link
Contributor Author

aivuk commented Sep 22, 2022

@aivuk this PR should be against dev-v2 right?

yes, sorry about that. I already changed it to dev-v2 now

@aivuk aivuk self-assigned this Sep 22, 2022
@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #69 (fff8dc5) into dev-v2 (455090b) will decrease coverage by 0.16%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##           dev-v2      #69      +/-   ##
==========================================
- Coverage   84.48%   84.31%   -0.17%     
==========================================
  Files          24       24              
  Lines        2062     2078      +16     
==========================================
+ Hits         1742     1752      +10     
- Misses        320      326       +6     
Impacted Files Coverage Δ
ckanext/validation/plugin/__init__.py 96.24% <ø> (ø)
ckanext/validation/tests/helpers.py 100.00% <ø> (ø)
ckanext/validation/jobs.py 82.85% <81.25%> (-0.87%) ⬇️
ckanext/validation/helpers.py 88.88% <87.50%> (-0.86%) ⬇️
ckanext/validation/logic.py 68.27% <100.00%> (-0.13%) ⬇️
ckanext/validation/tests/test_form.py 100.00% <100.00%> (ø)
ckanext/validation/tests/test_jobs.py 100.00% <100.00%> (ø)
ckanext/validation/tests/test_logic.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roll
Copy link
Contributor

roll commented Oct 25, 2022

TBH I don't fully understand a new approach. If there is still a field for CKAN end-users called "validation_options" - how they will be filling it if framework@5 doesn't even have this concept of validation options? I thought it was for internal representation, not user-facing.

@aivuk
Copy link
Contributor Author

aivuk commented Oct 25, 2022

TBH I don't fully understand a new approach. If there is still a field for CKAN end-users called "validation_options" - how they will be filling it if framework@5 doesn't even have this concept of validation options? I thought it was for internal representation, not user-facing.

The ckanext-validation is running the function validate from frictionless framework. If an user wants to pass parameters to the validate as skip_errors or pick_errors, or customize the dialect, or pass parameters to the validation checks, s/he is going to do it passing a json in the "validation options" field.

Can you please elaborate on the first question (how to pass)?

I mean a simple list with all the checks options names as 'table-dimensions' and their parameters. The only list that I could find was for the baseline checks but there is no documentation for what each one does https://framework.frictionlessdata.io/docs/checks/baseline.html

@aivuk
Copy link
Contributor Author

aivuk commented Oct 25, 2022

@roll Just an example, currently the user can put in the validation options field the json:

{
  "checks: [
    {"type": "table-dimensions", "minRows": 3},
    {"type": 'ascii-value'}
  ],
  "dialect": {
     "header": true,
     "headerRows": [1],
     "commentChar": "#",
     "csv": {
       "delimiter": ";"
     }
  }
}

Copy link
Member

@amercader amercader left a comment

Choose a reason for hiding this comment

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

@aivuk this looks good, just some polishing of the docs and tests and we can merge this

We can iron out things in separate PRs

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
ckanext/validation/jobs.py Show resolved Hide resolved
@@ -1,7 +1,6 @@
{% import 'macros/form.html' as form %}

{% set value = data[field.field_name] %}
{% set is_url = value and value[4:]|lower == 'http' %}
Copy link
Member

Choose a reason for hiding this comment

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

ping, I think this line should stay


assert validation.report["valid"] is True
# TODO: The vollowing test is not valid on frictionless v5.
# The local path is not hidden and there is no warning for more
Copy link
Member

Choose a reason for hiding this comment

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

I think these tests should be reactivated no?

@@ -1,3 +1,5 @@
ckantoolkit>=0.0.3
goodtables==1.5.1
frictionless==5.0.0b9
Copy link
Member

Choose a reason for hiding this comment

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

Sure, as soon as frictionless v5 goes out of beta we'll target the stable version

README.md Show resolved Hide resolved
Co-authored-by: Adrià Mercader <amercadero@gmail.com>
@amercader
Copy link
Member

@roll

TBH I don't fully understand a new approach. If there is still a field for CKAN end-users called "validation_options" - how they will be filling it if framework@5 doesn't even have this concept of validation options? I thought it was for internal representation, not user-facing.

We just need a way for users for inputing parameters for the validate() call. Right now we have this existing field which accepts a JSON object so it's easy to dump everything there rather than create separate checks, dialect, skip_errors etc fields in the form. The end goal should be to have a proper UI for tweaking all these settings, which I assume would be another frictionless component. When that's ready we'll refactor the form to use this and internally we'll settle on a way to pass the parameters to frictionless' validate() function

@roll
Copy link
Contributor

roll commented Oct 25, 2022

@amercader
That totally sounds good as an intermediate step. Just wanted to ensure that we're on the same page regarding the final vision (a UI component field instead of the validation_options field)

@@ -49,6 +49,8 @@ jobs:
run: |
pip install -r dev-requirements.txt
pip install -r requirements.txt
pip install --no-warn-conflicts jinja2==2.10.1
Copy link
Contributor

@ThrawnCA ThrawnCA Oct 26, 2022

Choose a reason for hiding this comment

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

This flag is concerning. Why can't conflicts be resolved? There should at least be a comment to explain why this is being done and what would be needed to address it.

Copy link
Member

Choose a reason for hiding this comment

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

@ThrawnCA this will be solved with upcoming requirement changes in frictionless-py. We just added this to not block the tests on this branch.

@aivuk would be good to sort this out on frictionless-py. IIRC it's just loosening up the requirements

README.md Outdated Show resolved Hide resolved
@amercader amercader merged commit 88b52db into dev-v2 Oct 27, 2022
@amercader amercader deleted the use-frictionless-framework-v5 branch October 27, 2022 09:31
@amercader
Copy link
Member

Great work @aivuk ! 🚀

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.

4 participants