-
Notifications
You must be signed in to change notification settings - Fork 795
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
Add $schema to top-level specs #370
Comments
+1
…On Tue, Aug 8, 2017 at 12:15 PM, Jake Vanderplas ***@***.***> wrote:
We should point to schemas as listed at https://github.com/vega/schema
Also should use these schemas directly for Altair's API generation.
I'd like to tackle this once #364
<#364> is merged.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#370>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABr0E8mPRTo-Icd_6u-zXVI1uCGZo4iks5sWLO-gaJpZM4OxK4t>
.
--
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
|
I'm looking at this now. I could patch it onto altair pretty easily, but trying to address it within A JSON schema can contain keys like "$schema" and "$id" which are not valid Python variable names, and thus can't be defined within traitlets in the standard way. Once a import traitlets as T
class Foo(T.HasTraits):
pass
f = Foo()
f.add_traits(**{'$schema': T.Unicode()})
f.set_trait('$schema', 'http://myurl.com/schema.json')
print(getattr(f, '$schema'))
Is there a good way to add a non-conforming trait name like this to a class rather than to an instance as above? Maybe construct the class using the metaclass directly? |
Not that I know of. Another option would be to add that in the to_dict()
layer?
…On Wed, Aug 9, 2017 at 11:34 AM, Jake Vanderplas ***@***.***> wrote:
I'm looking at this now. I could patch it onto altair pretty easily, but
trying to address it within schemapi brought up a challenge that you may
be able to help with, @ellisonbg <https://github.com/ellisonbg>:
A JSON schema can contain keys like "$schema" and "$id" which are not
valid Python variable names, and thus can't be defined within traitlets in
the standard way. Once a T.HasTraits class is instantiated, I can use the
add_traits() method to add non-conforming trait names; e.g.
import traitlets as T
class Foo(T.HasTraits):
pass
f = Foo()
f.add_traits(**{'$schema': T.Unicode()})
f.set_trait('$schema', 'http://myurl.com/schema.json')getattr(f, '$schema')
'http://myurl.com/schema.json'
Is there a good way to add a non-conforming trait name like this to a
*class* rather than to an *instance* as above?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#370 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABr0IL-QqC5KMUsv0RfJb0QFsX0t_m5ks5sWfuvgaJpZM4OxK4t>
.
--
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
|
Yeah, that's the easy way. But in terms of generality in |
Poking around, it looks like this works: Foo = T.MetaHasTraits('Foo', (T.HasTraits,), {'$schema': T.Unicode()})
print(Foo.class_traits())
though I think that's not ideal to start constructing all our classes that way... |
Yeah, I think using the to_dict(), while not ideal, it a bit more
pedestrian and easier to maintain.
…On Wed, Aug 9, 2017 at 11:40 AM, Jake Vanderplas ***@***.***> wrote:
Poking around, it looks like this works:
Foo = T.MetaHasTraits('Foo', (T.HasTraits,), {'$schema': T.Unicode()})print(Foo.class_traits())
{'$schema': <traitlets.traitlets.Unicode at 0x1069dd668>}
though I think that's not ideal to start constructing all our classes that
way...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#370 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABr0Id7lx7ZTUl_p6Cv3owIIpH6BJ-Rks5sWf0BgaJpZM4OxK4t>
.
--
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
[email protected] and [email protected]
|
Done in #372 |
We should point to schemas as listed at https://github.com/vega/schema
Also should use these schemas directly for Altair's API generation.
I'd like to tackle this once #364 is merged.
The text was updated successfully, but these errors were encountered: