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

Allow passing in traitlets via commandline #1123

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

yuvipanda
Copy link
Collaborator

Without this, you always needed a repo2docker_config.py
file to configure anything. This PR makes r2d match the
behavior of most traitlets based applications (like jupyter_server,
jupyterhub, nbconvert, etc)

Fixes #1112

Without this, you *always* needed a repo2docker_config.py
file to configure anything. This PR makes r2d match the
behavior of most traitlets based applications (like jupyter_server,
jupyterhub, nbconvert, etc)

Fixes jupyterhub#1112
@yuvipanda yuvipanda requested review from minrk and manics January 26, 2022 09:19
@manics
Copy link
Member

manics commented Jan 26, 2022

Do you know how to get the --help-all argument working? E.g. for jupyterhub

$ jupyterhub --help
...
Options
=======
The options below are convenience aliases to configurable class-options,
as listed in the "Equivalent to" description-line of the aliases.
To see all configurable class-options for some <cmd>, use:
    <cmd> --help-all

...
$ jupyterhub --help-all
...
Class options
=============
The command-line option below sets the respective configurable class-parameter:
    --Class.parameter=value
This line is evaluated in Python, so simple expressions are allowed.
For instance, to set `C.a=[0,1,2]`, you may type this:
    --C.a='range(3)'

Application(SingletonConfigurable) options
------------------------------------------
--Application.log_datefmt=<Unicode>
    The date format used by logging formatters for %(asctime)s
    Default: '%Y-%m-%d %H:%M:%S'

...

@yuvipanda
Copy link
Collaborator Author

@manics so we're mixing argparse and traitlets here, which is causing some of these issues. Ideally we would just be using traitlets and this will go away... I'm not entirely sure how to get --help-all working, other than to try get rid of argparse.

Copy link
Member

@manics manics left a comment

Choose a reason for hiding this comment

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

@minrk Do you know of an easy fix? If not let's merge!

a bit funky, since we are combining two separate parsers
@minrk
Copy link
Member

minrk commented Jan 27, 2022

I added --help-all. Application().print_help() is the method to call (classes=True is --help-all).

It does get a little funky, since there are two full argparse CLI instances running now (the one generated by traitlets, and our handcrafted one). I think if we want to have full traitlets CLI parsing, perhaps we should use traitlets CLI parsing. I understand not wanting to do that (it's simpler and nicer to write your own parser), but if we want the --Class.trait=value magic, it might be better to go all-in. We ought to get things like --show-config and friends for free, too.

@manics
Copy link
Member

manics commented Jan 27, 2022

CI failure is unrelated

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 5, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python3.5/site-packages/notebook/notebookapp.py", line 134, in <module>
    from .terminal import TerminalManager
  File "/usr/local/lib/python3.5/site-packages/notebook/terminal/__init__.py", line 4, in <module>
    import terminado
  File "/usr/local/lib/python3.5/site-packages/terminado/__init__.py", line 7, in <module>
    from .websocket import TermSocket
  File "/usr/local/lib/python3.5/site-packages/terminado/websocket.py", line 87
    self.log_terminal_output(f'STDOUT: {content[1]}')

Also occurred on main this morning 😞 https://github.com/jupyterhub/repo2docker/runs/4963525952?check_suite_focus=true

@yuvipanda
Copy link
Collaborator Author

@minrk agree going all inn is probably a good idea. Do you want me to do that to move this PR forward? Or can / should it be deferred?

@minrk
Copy link
Member

minrk commented Jan 27, 2022

Or can / should it be deferred?

It's fine to defer it. The biggest downside right now is that the --help-all output is a little confusing since two parsers each think they are displaying all the options, so the flow is a bit awkward.

CI failure is unrelated

The test failure is a metadata bug in terminado 0.13. Should be fixed by jupyter/terminado#140 once 0.13.0 is yanked.

@manics
Copy link
Member

manics commented Jan 27, 2022

Green! 🚀

Thanks all!

@manics manics merged commit 8c21b96 into jupyterhub:main Jan 27, 2022
@manics
Copy link
Member

manics commented Jan 27, 2022

Follow-up issue here: #1129

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.

Add docker options to repo2docker
3 participants