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

Metadata handling updates #53

Merged
merged 14 commits into from
Jul 26, 2015
Merged

Metadata handling updates #53

merged 14 commits into from
Jul 26, 2015

Conversation

jasongrout
Copy link
Member

This PR implements the changes from #52.

TODO:

  • Make metadata use local member when instantiating a new HasTraits
  • deprecation warning
  • add tag method
  • change tests
  • fix configure code
  • Don't do the deprecation warning if just specifying the help argument

@@ -64,7 +64,8 @@
#-----------------------------------------------------------------------------
# Basic classes
#-----------------------------------------------------------------------------

import warnings
warnings.filterwarnings('always')
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove these in the final PR

@jasongrout jasongrout force-pushed the metadata branch 6 times, most recently from a79ed5f to 184b694 Compare July 22, 2015 19:23
@jasongrout jasongrout changed the title IN-PROGRESS Metadata handling updates Metadata handling updates Jul 22, 2015
@jasongrout
Copy link
Member Author

I think this is ready for review.

@ellisonbg
Copy link
Member

Great, thanks!

On Wed, Jul 22, 2015 at 12:25 PM, Jason Grout notifications@github.com
wrote:

I think this is ready for review.


Reply to this email directly or view it on GitHub
#53 (comment).

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@Carreau
Copy link
Member

Carreau commented Jul 23, 2015

You emacs seem to make the test fail.

@jasongrout
Copy link
Member Author

hehe...couldn't be emacs, must be human error :)

@jasongrout
Copy link
Member Author

All the above PRs to the various repos are works-in-progress.

@jasongrout
Copy link
Member Author

Yep, you're right. I was over-eager in my replacements early on, including here.

Edit: Fixed, rebased, and pushed.

@jasongrout
Copy link
Member Author

Actually, we should probably make help a first-class argument of the constructor on this PR too. So this is still WIP.

@jasongrout jasongrout changed the title Metadata handling updates [WIP] Metadata handling updates Jul 23, 2015
@jasongrout
Copy link
Member Author

rebased on master...

@@ -359,13 +358,21 @@ def __init__(self, default_value=Undefined, allow_none=None, read_only=None, **m
)

if len(metadata) > 0:
warn("metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')", DeprecationWarning, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

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

This should include the metadata keys being set. Most people who encounter this message won't have any idea what values are metadata and what aren't.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call!

@jasongrout
Copy link
Member Author

We'll do the help promotion in another PR. It's sufficiently invasive and different that it deserves its own discussion.

@jasongrout
Copy link
Member Author

Okay, this is ready again for review.

@@ -368,7 +368,7 @@ class SomeSingleton(SingletonConfigurable):
pass

class DefaultConfigurable(Configurable):
a = Integer(config=True)
a = Integer().tag(config=True)
def _config_default(self):
if SomeSingleton.initialized():
return SomeSingleton.instance().config
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep some tests that pass config=True in the constructor to ensure we are preserving the deprecated behavior? I know it's tested at the lower level in traitlets, but I'd like to keep one or two here, as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Which test(s) do you want? I'll copy it and check for the deprecation warning too.

Copy link
Member

Choose a reason for hiding this comment

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

Just one or two of the simplest existing tests. All I really care about is keeping track of a = Trait(config=True) still working and loading its value from the config object.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, then jasongrout@eab41d6 should be sufficient (i.e., the commit below).

An earlier commit accidentally introduced a second TestTraitType class
that overrode the first, so about 10 tests weren't being run.
@jasongrout jasongrout changed the title [WIP] Metadata handling updates Metadata handling updates Jul 23, 2015
minrk added a commit that referenced this pull request Jul 26, 2015
Add .tag method for adding metadata

deprecate metadata as `**kwargs` in constructor
@minrk minrk merged commit c661f4b into ipython:master Jul 26, 2015
@jasongrout jasongrout deleted the metadata branch July 29, 2015 21:09
@SylvainCorlay SylvainCorlay mentioned this pull request Aug 4, 2015
@jdfreder
Copy link
Member

Will this be released in the next traitlet minor? Trying to decide when to merge Jason's widget PR - and for what version of widgets.

@SylvainCorlay
Copy link
Member

I guess that we can require the next minor traitlets release in ipywidgets as soon as it is out.

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

6 participants