forked from catherinedevlin/ipython-sql
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM mcr.microsoft.com/devcontainers/anaconda:0-3 | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
# && apt-get -y install --no-install-recommends <your-package-list-here> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "Jupyter", | ||
"build": { | ||
"context": "..", | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/git:1": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-toolsai.jupyter", | ||
"GitHub.codespaces" | ||
] | ||
} | ||
}, | ||
"postCreateCommand": "./.devcontainer/postCreate.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -x | ||
|
||
conda init bash | ||
|
||
# Perform install instructions from | ||
# https://ploomber-contributing.readthedocs.io/en/latest/contributing/setup.html | ||
conda create --name ploomber-base python=3.10 --yes | ||
conda activate ploomber-base | ||
pip install pkgmt | ||
pkgmt setup --doc | ||
|
||
# After the devcontainer comes up, you can just enable the jupysql conda env: | ||
# conda activate jupysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
jupytext: | ||
notebook_metadata_filter: myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.5 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
myst: | ||
html_meta: | ||
description lang=en: Display cell runtime in JupyterLab | ||
keywords: jupyter, jupyterlab, sql | ||
property=og:locale: en_US | ||
--- | ||
|
||
# Benchmarking runtime | ||
To record the time taken to run each cell | ||
in JupyterLab, we suggest using `jupyterlab-execute-time` | ||
|
||
## Installation | ||
|
||
```sh | ||
pip install jupyterlab_execute_time | ||
``` | ||
|
||
## Usage | ||
This plugin displays the metadata collected by the | ||
JupyterLab notebook, to ensure that the time is collected | ||
as part of the metadata, enable the record-time feature in | ||
notebook settings | ||
`Settings -> Notebook -> Recording timing` | ||
|
||
### Change notebook settings | ||
|
||
![syntax](../static/benchmarking-time_1.png) | ||
|
||
### Sample notebook | ||
|
||
![syntax](../static/benchmarking-time_2.png) | ||
|
||
Each executed cell shows the last executed time | ||
and the runtime | ||
|
||
![syntax](../static/benchmarking-time_3.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def test_trailing_semicolons_removed_from_cte(ip): | ||
ip.run_cell( | ||
"""%%sql --save positive_x | ||
SELECT * FROM number_table WHERE x > 0; | ||
""" | ||
) | ||
|
||
ip.run_cell( | ||
"""%%sql --save positive_y | ||
SELECT * FROM number_table WHERE y > 0; | ||
""" | ||
) | ||
|
||
cell_execution = ip.run_cell( | ||
"""%%sql --save final --with positive_x --with positive_y | ||
SELECT * FROM positive_x | ||
UNION | ||
SELECT * FROM positive_y; | ||
""" | ||
) | ||
|
||
cell_final_query = ip.run_cell( | ||
"%sqlrender final --with positive_x --with positive_y" | ||
) | ||
|
||
assert cell_execution.success | ||
assert cell_final_query.result == ( | ||
"WITH `positive_x` AS (\nSELECT * " | ||
"FROM number_table WHERE x > 0), `positive_y` AS (\nSELECT * " | ||
"FROM number_table WHERE y > 0)\nSELECT * FROM positive_x\n" | ||
"UNION\nSELECT * FROM positive_y;" | ||
) |