-
Notifications
You must be signed in to change notification settings - Fork 22
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
Adopt sp-repo-review #89
Changes from 4 commits
8d3e7e7
90902a8
2baae86
8f30efe
ab07dc6
01b64bb
9aad91a
d514904
5aaaee1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 2 | ||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.9" | ||
sphinx: | ||
configuration: docs/source/conf.py | ||
python: | ||
install: | ||
# install itself with pip install . | ||
- method: pip | ||
path: . | ||
extra_requirements: | ||
- docs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ from jupyter_events import Event | |
|
||
|
||
class MyApplication(JupyterApp): | ||
|
||
classes = [EventLogger, ...] | ||
eventlogger = Instance(EventLogger) | ||
|
||
|
@@ -21,32 +20,32 @@ class MyApplication(JupyterApp): | |
Register an event schema with the logger. | ||
|
||
```python | ||
schema = """ | ||
$id: http://myapplication.org/my-method | ||
version: 1 | ||
title: My Method Executed | ||
description: My method was executed one time. | ||
properties: | ||
msg: | ||
title: Message | ||
type: string | ||
""" | ||
|
||
self.eventlogger.register_event_schema( | ||
schema=schema | ||
) | ||
schema = """ | ||
$id: http://myapplication.org/my-method | ||
version: 1 | ||
title: My Method Executed | ||
description: My method was executed one time. | ||
properties: | ||
msg: | ||
title: Message | ||
type: string | ||
""" | ||
|
||
self.eventlogger.register_event_schema(schema=schema) | ||
``` | ||
|
||
Call `.emit(...)` within the application to emit an instance of the event. | ||
|
||
```python | ||
def my_method(self): | ||
# Do something | ||
... | ||
# Emit event telling listeners that this event happened. | ||
self.eventlogger.emit(schema_id="myapplication.org/my-method", data={"msg": "Hello, world!"}) | ||
# Do something else... | ||
... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. This indent is intentional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this was auto-formatted by blacken-docs, maybe we need to skip this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by skipping |
||
def my_method(self): | ||
# Do something | ||
... | ||
# Emit event telling listeners that this event happened. | ||
self.eventlogger.emit( | ||
schema_id="myapplication.org/my-method", data={"msg": "Hello, world!"} | ||
) | ||
# Do something else... | ||
... | ||
``` | ||
|
||
Great! Now your application is logging events from within. Deployers of your application can configure the system to listen to this event using Jupyter's configuration system. This usually means reading a `jupyter_config.py` file like this: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indent here was intentional, since it's part of the method from the preview code chunk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed