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

Added support to download example datasets #24

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rjoberon
Copy link

@rjoberon rjoberon commented Mar 1, 2024

Dear Sebastian,

Inspired by other libraries (e.g., Seaborn and scikit-learn) I have added support to download exemplary contexts from the repository https://github.com/fcatools/contexts. For more context, please have a look at this post on the FCA mailing list.

We can discuss details on how to properly handle, curate and implement this but I hope you like the idea. I'd happily make you (co)owner of the conexts repo or https://github.com/orgs/fcatools/ such that you have control over what can be loaded.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (90214c2) to head (6890a51).

❗ Current head 6890a51 differs from pull request most recent head 2000348. Consider uploading reports for the commit 2000348 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #24   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        24    +1     
  Lines         1462      1471    +9     
=========================================
+ Hits          1462      1471    +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@xflr6 xflr6 left a comment

Choose a reason for hiding this comment

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

Thanks!



# inspired by https://github.com/mwaskom/seaborn/blob/master/seaborn/utils.py#L524
def load_dataset(name: str, data_src: typing.Optional[str] = DATASET_SOURCE,
Copy link
Owner

Choose a reason for hiding this comment

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

nit: How about keyword-only arguments for eveything except name (and maybe that one even positional-only)?

Copy link
Author

Choose a reason for hiding this comment

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

Good idea. I implemented this in the latest commits.


# TODO: implement caching here?

return Context.fromstring(urlopen(url).read().decode(encoding), 'cxt')
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we should use a context-manager for urlopen()?

Copy link
Author

Choose a reason for hiding this comment

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

Definitely. Done.

@@ -0,0 +1,10 @@
import pytest
Copy link
Owner

Choose a reason for hiding this comment

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

unused import

Copy link
Author

Choose a reason for hiding this comment

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

removed.



def test_load_dataset():
context = concepts.load_dataset('livingbeings_en')
Copy link
Owner

Choose a reason for hiding this comment

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

We should probbaly not depend on internet connectivity in the test.

How about having a mocked test and another one doing the actual thing that would be opt-in with a flag?

Something mildy related here: https://github.com/xflr6/graphviz/blob/e5578d39009469df2b7c6743458970643e228226/tests/conftest.py#L5

Copy link
Author

@rjoberon rjoberon Mar 15, 2024

Choose a reason for hiding this comment

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

I agree but I did not manage to implement this. The examples I found are mainly targeting unittest and not pytest (or pytest with the requests module).

@xflr6
Copy link
Owner

xflr6 commented Mar 3, 2024

Thanks for the PR.

We can discuss details on how to properly handle, curate and implement this but I hope you like the idea.

Of course :) In recent times, I did not have much time for my open source projects but it would still be nice to make at least some small improvements.

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.

3 participants