Skip to content

Add handling for no ref being provided#128

Merged
yuvipanda merged 1 commit intojupyterhub:masterfrom
betatim:fix-clone-depth
Nov 1, 2017
Merged

Add handling for no ref being provided#128
yuvipanda merged 1 commit intojupyterhub:masterfrom
betatim:fix-clone-depth

Conversation

@betatim
Copy link
Copy Markdown
Member

@betatim betatim commented Nov 1, 2017

Fixes the bug noticed (and reverted) here: jupyterhub/mybinder.org-deploy#112

We do not need to checkout a specific ref if none is provided. Added a test to check the behaviour.

The big question is: when does binderhub call repo2docker without a ref as commandline argument?

We do not need to checkout a specific ref if none is provided. Added a
test to check the behaviour.
Comment thread repo2docker/app.py
_checkout(ref)
# ref == None means we want to use HEAD so no need to checkout a
# specific revision
if ref is not None:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this fixes the bug

Comment thread tests/conftest.py
if self.ref is not None:
cmd = ['jupyter-repo2docker', '--ref', self.ref, self.url, '--']
else:
cmd = ['jupyter-repo2docker', self.url, '--']
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Needed to support the new test case that has no ref.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is also why tests passed, since --ref was before self.url!

@yuvipanda
Copy link
Copy Markdown
Collaborator

Currently it seems to fail even when you do give it a ref.

 jupyter-repo2docker https://github.com/binder-examples/requirements --ref master

Fails on master for me.

@betatim
Copy link
Copy Markdown
Member Author

betatim commented Nov 1, 2017

jupyter-repo2docker https://github.com/binder-examples/requirements --ref master also fails on master for me. Inspecting ref just before calling _contains gives None.

@yuvipanda
Copy link
Copy Markdown
Collaborator

Yup. Looks like it's related to argparse issue somewhere, most likely in the 'cmd' arg.

The following works:

jupyter-repo2docker --ref  d7f774a1af892319cd1483fa2255c24511876375 https://github.com/binder-examples/requirements

The following does not:

jupyter-repo2docker https://github.com/binder-examples/requirements --ref  d7f774a1af892319cd1483fa2255c24511876375

This is on this branch, not master.

@yuvipanda
Copy link
Copy Markdown
Collaborator

If anything, it looks like we'd just been building master for a while instead of whatever ref was passed in. Your PR removed the superfluous 'if not ref' line, causing the problem to actually show :)

@choldgraf
Copy link
Copy Markdown
Member

If anything, it looks like we'd just been building master for a while instead of whatever ref was passed in.

👌 nice ;-)

@betatim
Copy link
Copy Markdown
Member Author

betatim commented Nov 1, 2017

Agree, if you pass --ref after the URL then args.ref is None right after parsing the arguments. After that everything "works", except we lost the ref.

@yuvipanda
Copy link
Copy Markdown
Collaborator

I made a patch to binderhub: jupyterhub/binderhub#234

@yuvipanda yuvipanda merged commit d3286eb into jupyterhub:master Nov 1, 2017
@yuvipanda
Copy link
Copy Markdown
Collaborator

Ok, this can be deployed again, but jupyterhub/binderhub#234 should probably also be deployed alongside this to make sure we're actually building the versions we wanna.

@betatim betatim deleted the fix-clone-depth branch November 1, 2017 21:20
@betatim
Copy link
Copy Markdown
Member Author

betatim commented Nov 1, 2017

I think we should declare passing an --arg after the URL as undefined behaviour. If you do pass something after the URL (jupyter-repo2docker https://github.com/binder-examples/requirements --ref master) you get:

Namespace(build=True, clean=True, cmd=['--ref', 'master'],
config='repo2docker_config.py', debug=False, image_name=None,
json_logs=False, push=False, ref=None,
repo='https://github.com/binder-examples/requirements', run=True)

from parse_args(). We could inspect cmd to see if it contains an argument that is also a repo2docker argument and then exit. However I think that is a bit too much heuristics (you could legitimately have a --ref in the command you want to execute).

markmo pushed a commit to markmo/repo2docker that referenced this pull request Jan 22, 2021
Add handling for no ref being provided
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