Skip to content

Commit

Permalink
update README example (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Kafonek authored Aug 9, 2023
1 parent 7d75214 commit 5912554
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ from origami.models.notebook import CodeCell
cell = CodeCell(source="print('Hello World')")
await realtime_notebook.add_cell(cell)

# Execute the cell
# Execute the cell. The returned value is a dictionary of Futures. Awaiting those futures will
# block until the cells have completed execution
queued_execution = await realtime_notebook.queue_execution(cell.id)

# Wait for the execution to be complete, cell is an updated instance of CodeCell with metadata/outputs
cell = await queued_execution
# The return value of the Futures is the up-to-date cell. If there's output, an output collection id
# will be set on the cell metadata
cells = await asyncio.gather(*queued_execution)

# Grab the output
cell = cells[0]
output_collection = await api_client.get_output_collection(cell.output_collection_id)
print(output_collection.outputs[0].content.raw) # 'Hello World\n'
```
Expand Down

0 comments on commit 5912554

Please sign in to comment.