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

Ref resolution scope #68

Merged
merged 4 commits into from Feb 22, 2013

Conversation

gazpachoking
Copy link
Contributor

Okay, I think this resolves 😜 the issue mentioned in #66. It at least passes the tests I have at json-schema-org/JSON-Schema-Test-Suite#34

@Julian, how do you feel about this method?

@Julian
Copy link
Member

Julian commented Feb 20, 2013

So is resolve a useful function anymore? It's never called by us anymore and it seems anyone resolving a ref would always need the new scope too. Is that right?

@gazpachoking
Copy link
Contributor Author

Yeah, seems right. I mostly left it in as the path of least resistance to see if unit tests were still passing. :P It can certainly come out though.

@Julian
Copy link
Member

Julian commented Feb 20, 2013

So would something that looks like:

with ref_resolver.resolving(ref) as resolved:
    self.validate(instance, resolved)

work instead of both methods? Will that work for whatever other cases we'll
need to deal with?
On Feb 20, 2013 2:14 PM, "Chase Sterling" notifications@github.com wrote:

Yeah, seems right. I mostly left it in as the path of least resistance to
see if unit tests were still passing. :P It can certainly come out though.


Reply to this email directly or view it on GitHubhttps://github.com//pull/68#issuecomment-13850448.

@gazpachoking
Copy link
Contributor Author

Hehe, that sounds an awful lot like my first implementation :P I do like it though. We may need to keep the in_scope method to deal with id keyword from iter_errors method.

@gazpachoking
Copy link
Contributor Author

How about in unit tests, are we going to use the resolving context manager still?

@gazpachoking
Copy link
Contributor Author

I guess it only makes sense.

which changes the scope and returns referenced schema
@gazpachoking
Copy link
Contributor Author

I implemented your idea, and updated the tests. Seem better now?

@Julian
Copy link
Member

Julian commented Feb 21, 2013

Awesome, do you think this will be robust enough for what you have in mind for whatever else we'll need?

@gazpachoking
Copy link
Contributor Author

Yeah, this solution seems good to me. The only thing I was thinking about, is that if someone turns off cache_remote, the remote schemas will be fetched again for any json pointer references within them.

@gazpachoking
Copy link
Contributor Author

I have an idea for that though. Gimme a few.

@gazpachoking
Copy link
Contributor Author

@Julian That should take care of previously mentioned issue. Seem decent?

@Julian
Copy link
Member

Julian commented Feb 21, 2013

Looks great! Gonna play with it locally for a bit and then we can merge.

@gazpachoking
Copy link
Contributor Author

Should we make the json tests run with a custom RefResolver, and just load the results of jsonschema_suite remotes into the store to get the new tests running?

@Julian
Copy link
Member

Julian commented Feb 22, 2013

Um. Well I think the idea for the remotes was to actually get all the way to the point where some HTTP request was about to be fired, not just sticking in the store and relying on the cache. So e.g. stubbing out requests / urllib to return those remotes.

@Julian
Copy link
Member

Julian commented Feb 22, 2013

After that if the tests pass feel free to merge.

@gazpachoking
Copy link
Contributor Author

Ahh, yeah, I was mostly thinking about testing the resolution went correctly. But it makes sense to test more of the code and mock the actual request. I'm almost certainly going to come up with some suboptimal way to get this going, you can show me how it should be done after that. :P

@Julian
Copy link
Member

Julian commented Feb 22, 2013

Heh OK ;) check out mock.Mock.side_effect and probably just set it to the remotes dict's .get if that makes sense.

@gazpachoking
Copy link
Contributor Author

I'm a bit confused about what you mean with side_effect, I do have something working now, I'm having an issue with running on python 3 though, as jsonschema_suite is not python 3 compatible.

@gazpachoking
Copy link
Contributor Author

Should it just use the remotes folder from the suite rather than running jsonschema_suite remotes?

@gazpachoking
Copy link
Contributor Author

This is what I'm doing right now btw https://gist.github.com/gazpachoking/02c741d436a0a1b4546c

@Julian Julian merged commit c327a3f into python-jsonschema:master Feb 22, 2013
@Julian
Copy link
Member

Julian commented Feb 22, 2013

OK merged. See 65a0e17 for what I meant, sorry I sucked at explaining it.

Feel free to improve upon anything you see fit.

@Julian Julian mentioned this pull request Feb 22, 2013
@Julian
Copy link
Member

Julian commented Feb 22, 2013

Oh I guess I broke 2.6 by using check_output.

@Julian
Copy link
Member

Julian commented Feb 22, 2013

I think 2.6 is going to be broken anyhow because it doesn't support 2.6. So I'll skip these for now on 2.6.

@gazpachoking
Copy link
Contributor Author

Yeah, I knew you were going to come up with something cleaner. :) Also, pretty sure I had it working with 2.6, I also started with check_output, but removed it for that.

@Julian
Copy link
Member

Julian commented Feb 22, 2013

I see what you had, but bin/jsonschema_suite doesn't support 2.6. Unless I install argparse. I guess I can do that and add it to tox.ini.

@gazpachoking
Copy link
Contributor Author

Oh yeah. I did that too. :P

@gazpachoking
Copy link
Contributor Author

I'm not too concerned whether remotes get tested on 2.6 though, just wanted to point out it was possible.

@Julian
Copy link
Member

Julian commented Feb 22, 2013

OK, neither am I. We'll leave it for now. py3 is also failing beacuse of stupid json.load not taking actual non-text file objects I'm sure. I'm not really in the mood to debug that atm.

@Julian
Copy link
Member

Julian commented Feb 24, 2013

Think I'm gonna do a release. Anything you think is outstanding to get done beforehand?

@gazpachoking
Copy link
Contributor Author

The FormatChecker stuff was the only thing I was thinking.

@Julian
Copy link
Member

Julian commented Feb 24, 2013

Ah, okay. We can do that after the release then. Just checking over the
documentation to make sure it's all accurate still.
On Feb 24, 2013 1:46 PM, "Chase Sterling" notifications@github.com wrote:

The FormatChecker stuff was the only thing I was thinking.


Reply to this email directly or view it on GitHubhttps://github.com//pull/68#issuecomment-14013333.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something doesn't work the way it should.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants