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

ENH: Redirect github blob URLs to raw.github URLs #118

Merged
merged 1 commit into from
Nov 18, 2013

Conversation

westurner
Copy link
Contributor

  • Factored out URI value parsing logic
  • Compile REGEXes once
  • Doctest
  • Removed ambiguous form handling logic

- Global REGEXes
- Factored out URI value parsing logic
- Doctest
@westurner
Copy link
Contributor Author

@minrk
I started to add a unittest import but instead opted for doctests w/ this patch.

I see:

If I was to write tests (and a tox.ini) for this application, is there a preference for/against:

  1. a ./tests directory
  2. http://webtest.pythonpaste.org/en/latest/
  3. http://flask.pocoo.org/docs/testing/

@minrk
Copy link
Member

minrk commented Nov 16, 2013

We are just about to refactor nbviewer entirely (drop flask for tornado, use async, etc.) That WIP also does this redirect. As for tests, a tests subpackage in the nbviewer package would be how we've done things for most projects.

@minrk
Copy link
Member

minrk commented Nov 16, 2013

Given the problems with Python 3 and dictionary ordering, in IPython, we have moved away from doctests, as we have found them to be more trouble than they are worth.

@minrk
Copy link
Member

minrk commented Nov 16, 2013

I actually misread this - we actually should be avoiding GitHub raw URLs, and redirecting those to GitHub API requests, rather than pushing more requests toward them.

@westurner
Copy link
Contributor Author

Given the problems with Python 3 and dictionary ordering, in IPython, we have moved away from doctests, as we have found them to be more trouble than they are worth.

Aren't the same problems inherent to unittest ordering? (and PYTHONHASHSEED?)
I sometimes work around this by including three-digit numeric fields in the test method name / key.

@westurner
Copy link
Contributor Author

We are just about to refactor nbviewer entirely (drop flask for tornado, use async, etc.)

So there will be a new dependency on teh tornado web server?

That WIP also does this redirect. As for tests, a tests subpackage in the nbviewer package would be how we've done things for most projects.

I may be able to find the time to help with writing tests, given a link to a branch/repo.

I actually misread this - we actually should be avoiding GitHub raw URLs, and redirecting those to GitHub API requests, rather than pushing more requests toward them.

Why?

@Carreau
Copy link
Member

Carreau commented Nov 17, 2013

So there will be a new dependency on teh tornado web server?

Probably yes, Flask is blocking which is annoying for a service like nbviewer where you cannot rely on time of remote to respond.

I actually misread this - we actually should be avoiding GitHub raw URLs, and redirecting those to GitHub API requests, rather than pushing more requests toward them.
Why?

Raw github url are not supposed to be un-changing, changes in github API are planed. Also it help github know why their url is fetched by someone or a remote service, and make optimisation based on that.
Finally using API would trivially allow nbviewer to access private github repo if install locally which interest some peoples.

@westurner
Copy link
Contributor Author

@westurner
Copy link
Contributor Author

Raw github url are not supposed to be un-changing, changes in github API are planed.

Are you suggesting that raw github links are going away? Is there a link describing this roadmap?

So the GitHub API is less stable than the HTTP API, and that's why it is needed to use the API?

Also it help github know why their url is fetched by someone or a remote service, and make optimisation based on that.

They need more than a user agent string to serve comperssed plaintext over HTTPS?

Finally using API would trivially allow nbviewer to access private github repo if install locally which interest some peoples.

Good point. So there are different URL routes in this new version of nbviewer?

Fate of this pull request

That's great that this functionality is in the new version. As it is, the live version of nbviewer does not support this functionality (and recompiles regexes on every view invocation).

Would you like me to:
a) add unittests instead of doctests (maybe with optparse/argparse and a '-t' option)

  • inline or separate file?

b) just drop this patch and close the pull request

c) other

@minrk
Copy link
Member

minrk commented Nov 17, 2013

Why?

Actually, just because GitHub asked people to stop treating raw.github.com as a CDN, and that is precisely what we are doing. I don't think there is a great risk of raw URLs being unstable.

Fate of this pull request

I think we can merge this as-is, actually. It's strictly an improvement over the status quo. +1 to merge, @Carreau?

@minrk
Copy link
Member

minrk commented Nov 17, 2013

Current state of my tornado fiddling is at #120 now.

@Carreau
Copy link
Member

Carreau commented Nov 18, 2013

Yes +1 to merge as it is strictly an improvement. will look at #120 too.

minrk added a commit that referenced this pull request Nov 18, 2013
ENH: Redirect github blob URLs to raw.github URLs
@minrk minrk merged commit 269649d into jupyter:master Nov 18, 2013
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.

3 participants