You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable ServerApp to discover ExtensionApps (and their config). (#180)
* enable extensionapp config to be discoverable from serveapp
* add some comments for future devs
* allow None in non-ExtensionApp extensions
* adjust tests to capture changes
* minor bug fixes
* renamed config pytest fixture
* standardize extension loading mechanism
* pass serverapp and extesnionapp to extensionapp handlers
* use static url prefix for static paths
* iniitalize all enabled extension, then load later
* split extension initialization and loading
* Upgrade examples to align on discovery branch
* Polish examples
* Launch example via python module
* Avoid to run initialisation methods twice
* Add main for simple_ext2 and simple_ext11
* minor changes to extension toggler
* adding some comments throughout the code
* move all CLI handling to the ServerApp
* remove old traits from extensionapp
* update tests
* update tests with changes to extensionapp
* fix examples entrypoint
* add test dependency: pytest-lazy-fixture
* unpin pytest
* import lazyfixture directly due to changes in pytest
* drop pytest-lazy-fixture
* cleaner error handling in init_server_extension
* minor clean up
* minor fixes after review
* add underscore as prefix to extension function
* remove load_jupyter_server_extension from examples
* minor typo in example comment
Co-authored-by: Eric Charles <[email protected]>
Copy file name to clipboardExpand all lines: examples/simple/README.md
+25-10Lines changed: 25 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,12 @@ open http://localhost:8888/simple_ext1/redirect
67
67
open http://localhost:8888/static/simple_ext1/favicon.ico
68
68
```
69
69
70
+
You can also start the server extension with python modules.
71
+
72
+
```bash
73
+
python -m simple_ext1
74
+
```
75
+
70
76
## Extension 1 and Extension 2
71
77
72
78
The following command starts both the `simple_ext1` and `simple_ext2` extensions.
@@ -90,9 +96,12 @@ open http://localhost:8888/simple_ext2/params/test?var1=foo
90
96
Optionally, you can copy `simple_ext1.json` and `simple_ext2.json` configuration to your env `etc` folder and start only Extension 1, which will also start Extension 2.
91
97
92
98
```bash
93
-
pip uninstall -y jupyter_simple_ext&& \
99
+
pip uninstall -y jupyter_server_example&& \
94
100
python setup.py install && \
95
101
cp -r ./etc $(dirname $(which jupyter))/..
102
+
```
103
+
104
+
```bash
96
105
# Start the jupyter server extension simple_ext1, it will also load simple_ext2 because of load_other_extensions = True..
97
106
# When you invoke with the entrypoint, the default url will be opened in your browser.
98
107
jupyter simple-ext1
@@ -102,18 +111,20 @@ jupyter simple-ext1
102
111
103
112
Stop any running server (with `CTRL+C`) and start with additional configuration on the command line.
104
113
105
-
The provided settings via CLI will override the configuration that reside in the files (`jupyter_simple_ext1_config.py`...)
114
+
The provided settings via CLI will override the configuration that reside in the files (`jupyter_server_example1_config.py`...)
106
115
107
116
```bash
108
117
jupyter simple-ext1 --SimpleApp1.configA="ConfigA from command line"
109
118
```
110
119
111
-
Check the log, it should return on startup something like the following base on the trait you have defined in the CLI and in the `jupyter_simple_ext1_config.py`.
120
+
Check the log, it should return on startup print the Config object.
121
+
122
+
The content of the Config is based on the trait you have defined via the `CLI` and in the `jupyter_server_example1_config.py`.
112
123
113
124
```
114
125
[SimpleApp1] Config {'SimpleApp1': {'configA': 'ConfigA from file', 'configB': 'ConfigB from file', 'configC': 'ConfigC from file'}}
115
126
[SimpleApp1] Config {'SimpleApp1': {'configA': 'ConfigA from file', 'configB': 'ConfigB from file', 'configC': 'ConfigC from file'}}
116
-
[SimpleApp2] WARNING | Config option `configD` not recognized by `SimpleApp2`. Did you mean `config_file`?
127
+
[SimpleApp2] WARNING | Config option `configD` not recognized by `SimpleApp2`. Did you mean one of: `configA, configB, configC`?
117
128
[SimpleApp2] Config {'SimpleApp2': {'configD': 'ConfigD from file'}}
118
129
[SimpleApp1] Config {'SimpleApp1': {'configA': 'ConfigA from command line', 'configB': 'ConfigB from file', 'configC': 'ConfigC from file'}}
119
130
```
@@ -133,27 +144,31 @@ Try with the above links to check that only Extension 2 is responding (Extension
133
144
134
145
`Extension 11` extends `Extension 1` and brings a few more configs.
135
146
136
-
Run `jupyter simple-ext11 --generate-config && vi ~/.jupyter/jupyter_config.py`.
137
-
138
-
> TODO `--generate-config` returns an exception `"The ExtensionApp has not ServerApp "`
147
+
```bash
148
+
# TODO `--generate-config` returns an exception `"The ExtensionApp has not ServerApp "`
149
+
jupyter simple-ext11 --generate-config && vi ~/.jupyter/jupyter_config.py`.
150
+
```
139
151
140
152
The generated configuration should contains the following.
141
153
142
154
```bash
143
-
TBD
155
+
# TODO
144
156
```
145
157
146
158
The `hello`, `ignore_js` and `simple11_dir` are traits defined on the SimpleApp11 class.
147
159
148
160
It also implements additional flags and aliases for these traits.
149
161
150
-
+ The `--hello` flag will log on startup `Hello Simple11 - You have provided the --hello flag or defined a c.SimpleApp1.hello == True`.
151
-
+ The `--simple11-dir` alias will set `SimpleExt11.simple11_dir` settings.
162
+
- The `--hello` flag will log on startup `Hello Simple11 - You have provided the --hello flag or defined a c.SimpleApp1.hello == True`
163
+
- The `ignore_js` flag
164
+
- The `--simple11-dir`alias will set`SimpleExt11.simple11_dir` settings
152
165
153
166
Stop any running server and then start the simple-ext11.
0 commit comments