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

Make it easier to get optional information from load() #38

Closed
kalekundert opened this issue Feb 10, 2023 · 1 comment
Closed

Make it easier to get optional information from load() #38

kalekundert opened this issue Feb 10, 2023 · 1 comment

Comments

@kalekundert
Copy link
Owner

Right now, load() has two arguments which cause additional information to be returned:

  • extras: Return any keys from the TOML file that wellmap didn't use.
  • report_dependencies: Return a list of all the files that were read.

A few recent issues suggest that more information is needed:

It's not unlikely that I will want to add even more information like this in the future, too. It's already a bit unwieldy to keep track of what values are returned by load() in what order, and this will only get worse as more and more optional return values are added. Therefore, I think I should move to a signature that wraps all of this information into a single object. That way, adding new information will just mean adding a new attribute to this object; the signature of load() won't change.

Here's some pseudocode for what I have in mind:

def load(path, meta=False):
    # Load the layout in the usual way...

    meta_obj = Metadata(
            extras=extras,
            deps=deps,
            ...
    )
 
    if meta:
        return df, meta_obj
    else:
        return df

This would be a backwards-compatible change as long as I don't get rid of the current options. I would want to deprecate them, though, since they would just be making the code more complicated for no benefit.

@kalekundert
Copy link
Owner Author

Fixed by 5274c99

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

No branches or pull requests

1 participant