Skip to content

Commit

Permalink
🧪 mnt/vitest (#676)
Browse files Browse the repository at this point in the history
* `core` uses vitest
* `react` uses vitest
  • Loading branch information
stevejpurves authored Aug 21, 2023
1 parent 6e454a5 commit ecb07a5
Show file tree
Hide file tree
Showing 18 changed files with 8,818 additions and 546 deletions.
96 changes: 96 additions & 0 deletions apps/simple/static/paths.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html>
<head>
<title>Jupyter - Thebe Demo</title>
<!-- Configure and load Thebe !-->
<script type="text/x-thebe-config">
{
requestKernel: true,
mountActivateWidget: true,
mountStatusWidget: true,
useJupyterLite: false,
useBinder: false,
serverSettings: {
baseUrl: 'http://localhost:8888',
token: 'test-secret'
},
kernelOptions: {
path: '/notebooks'
}
}
</script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="thebe.css" />
<link rel="stylesheet" href="main.css" />
<script src="index.js"></script>
<style>
.CodeMirror {
max-width: 900px;
}
pre.code {
background-color: #eee;
padding: 16px;
}
</style>
</head>
<body>
<div style="margin: 24px auto; max-width: 900px">
<h1>Executing cells in context of the crrect notebook path</h1>
<p>
Even though thebe works with individual cells, it still executes them in the context of the
a session. Sessions pair an individual kernel with a notebook context that requires a notebook's location
to be specified. As no notebook exists this can see suplerflous but it is still required in order
to propoerly execute code that is dependent on relative paths.
</p>
<p>
Consider a jupyter server started in a root folder, which in turn contains a folder called <code>notebooks</code>.
<code>ipynb</code> files are located in the <code>notebooks</code> folder and are developed with
paths suitable for locaing a data file in a <code>data</code> folder located in the same folder as the notebook.
Without the path being correctly set to the notebook's location, the code will fail to execute.
</p>
<p>
To use this demo you will need to start a local jupyter folder in a root folder with the following structure:
<pre>
.
-- notebooks/
-- screening.ipynb
-- data/
-- data.csv
</pre>
The file <code>data.csv</code> can contain anything and the notebook should simply include the following python code:

<pre>
with open('data/data.csv', 'r') as f:
print(f.read())
</pre>
<p>

to to have a juptyer server available and able to receive connections
from <code>localhost</code>. To start a local server, use the following command:
</p>
<p>
<code>jupyter lab --NotebookApp.token=test-secret --NotebookApp.allow_origin='*'</code>
</p>
<div class="thebe-activate"></div>
<div class="thebe-status"></div>
<pre
style="background-color: #eee; padding: 16px"
data-executable="true"
data-language="python"
>
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('data/data.csv')
df.head()
</pre>
</div>
</body>
</html>
Loading

0 comments on commit ecb07a5

Please sign in to comment.