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

Let users never see Entry objects #490

Merged
merged 11 commits into from May 29, 2020
Merged

Conversation

martindurant
Copy link
Member

This is "unification light" - still have Entry objects, but the user doesn't see them. The catalog just gives you the default source directly, but you can override them with call or clone (maybe should be get??) to get a new version of the source. Note that .describe() will give you the original catalog definition (with user parameters), not your overridden version, but repr of the source now also gives you that YAML view with the current set of arguments.

cc @danielballan @tacaswell

@martindurant
Copy link
Member Author

(I'm sure a load of tests would need updating, but would like comments sooner rather than later)

def describe(self):
return self.entry.describe()

@property
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an application layer thing that should not be baked into the core objects. If this is something that was there and needs to stay for back compatibility can we deprecate it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, you could construct a GUI for an entry previously (which allowed you to select the user parameters and then plot with point&click); so if the user is no longer exposed to the entry object, this is the only way to do it. Of course, we could question the usefulness of that particular GUI view, but otherwise the source no longer has any connection to the GUIs at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes a lot more sense to me to pass the DateSrouce to the gui (make_the_clicky_gui(ds)) rather than have it be a method so that it is possible to support exposing several gui generation tactics to the user (ex "all the details" vs "executive summary").

Copy link
Member

Choose a reason for hiding this comment

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

I too would like to revisit this, but I think should not lump that into this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

The GUI code can probably do with a refactor following improvements in https://github.com/intake/filesystem_spec/blob/master/fsspec/gui.py#L14

intake/source/base.py Outdated Show resolved Hide resolved
intake/source/base.py Outdated Show resolved Hide resolved
intake/source/base.py Outdated Show resolved Hide resolved
intake/catalog/entry.py Outdated Show resolved Hide resolved
@tacaswell
Copy link
Contributor

Sorry for crashing into your code base with possibly more opinions than understanding.

@martindurant
Copy link
Member Author

Sorry for crashing into your code base with possibly more opinions than understanding.

It is appreciated!

@danielballan
Copy link
Member

Thanks for leading the way on this, @martindurant! I am still under a rock but should emerge next week to look at this.

@martindurant martindurant mentioned this pull request May 6, 2020
@martindurant martindurant changed the title WIP: Let users never see Entry objects Let users never see Entry objects May 11, 2020
@martindurant
Copy link
Member Author

Good to go, reviews appreciated!

(docs still need updating in some places; may have knock-on errors in dependent packages which need sorting before blanket releases)

@danielballan
Copy link
Member

I'd like to beg another week or so to look at this. Racing to prep for a big tutorial a week from tomorrow (unveiling databroker-refactored-on-top-of-intake among other things).

@martindurant
Copy link
Member Author

@danielballan , I can wait :)

intake/utils.py Outdated Show resolved Hide resolved
Copy link
Member

@danielballan danielballan left a comment

Choose a reason for hiding this comment

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

I am convinced that this approach is better than the one I had in mind. Retaining Entry as an internal entity will be useful for a least two reasons I can think of:

  • making new instances with different parameters cleanly
  • giving us a bundle of parameters that we can pickle, whereas DataSource instances themselves may carry un-pickleable resources like file handles or sockets

Also, this is clearly as an easier refactor than attempting to excise Entry from the codebase. :-)

I have a couple comments for your consideration. I would also like to test databroker against this branch before it is merged. Will post results today or tomorrow.

intake/catalog/entry.py Outdated Show resolved Hide resolved
intake/source/base.py Outdated Show resolved Hide resolved
def describe(self):
return self.entry.describe()

@property
Copy link
Member

Choose a reason for hiding this comment

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

I too would like to revisit this, but I think should not lump that into this PR.

intake/source/base.py Outdated Show resolved Hide resolved
intake/source/base.py Show resolved Hide resolved
intake/utils.py Outdated Show resolved Hide resolved
@danielballan
Copy link
Member

danielballan commented May 21, 2020

This requires some small changes to databroker but I now have a branch bluesky/databroker#569 that passes against this intake PR branch, intake master, and intake 0.5.5. I also took it for a spin interactively, and it behaves as expected.

Remaining concerns:

  • There is a back-compatibility issue with .get(). See this example using data-us-states. With intake 0.5.5:

    In [3]: intake.cat.states.get()                                                                                                                                                               
    Out[3]: <intake.source.csv.CSVSource at 0x7ff9771b50d0>

    With this PR branch

    In [3]:  intake.cat.states.get()                                 
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-5-e1dc9e0715d2> in <module>
    ----> 1 intake.cat.states.get()
    
    AttributeError: 'CSVSource' object has no attribute 'get'
  • Settling on a name for configure (I am fine with copy_and_configure, or other suggestions listed in line above.)

  • Removing sorted or making it conditional on Python version (again see comment above)

Thanks again @martindurant for taking this on.

@martindurant
Copy link
Member Author

Last call for comments

@martindurant
Copy link
Member Author

(updates to docs will follow merger and release)

@danielballan
Copy link
Member

I'm seeing a regression from the last commit but I don't understand it yet. Please hold merging while I investigate.

@danielballan
Copy link
Member

Looks like it was just a confusion on my end, I must have had different branches installed than I thought. Full steam ahead!

@danielballan
Copy link
Member

Rebased to resolve conflicts and force-pushed

@martindurant
Copy link
Member Author

Rebased to resolve conflicts and force-pushed

Did the same, but you were faster!

To https://github.com/martindurant/intake
 ! [rejected]        unify -> unify (fetch first)
error: failed to push some refs to 'https://github.com/martindurant/intake'

@danielballan
Copy link
Member

Welp, looks like I introduced a syntax error in rebase....

@martindurant
Copy link
Member Author

fixed...

@danielballan
Copy link
Member

Test failure is on one build, GUI related.

@danielballan danielballan merged commit 48360c9 into intake:master May 29, 2020
@martindurant martindurant deleted the unify branch May 29, 2020 14:47
@martindurant
Copy link
Member Author

You took the button press away from me! :)

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.

None yet

3 participants