Skip to content

Commit 6b5918a

Browse files
committed
Add trouble shooting
1 parent 4c3e018 commit 6b5918a

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

docs/trouble_shooting.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Trouble shooting
2+
3+
## When `flux` fails:
4+
5+
### Step-by-Step Guide to Create a Custom Jupyter Kernel for Flux
6+
7+
#### Step 1: Create a New Kernel Specification
8+
9+
1. Install [`flux-core`](https://anaconda.org/conda-forge/flux-core) in your Jupyter environment:
10+
11+
```bash
12+
conda install -c conda-forge flux-core
13+
```
14+
15+
2. **Find the Jupyter Kernel Directory**:
16+
17+
Open your terminal or command prompt and run:
18+
19+
```bash
20+
jupyter --paths
21+
```
22+
23+
This command will display the paths where Jupyter looks for kernels. You'll usually find a directory named `kernels` under the `jupyter` data directory. You will create a new directory for the Flux kernel in the `kernels` directory.
24+
25+
3. **Create the Kernel Directory**:
26+
27+
Navigate to the kernels directory (e.g., `~/.local/share/jupyter/kernels` on Linux or macOS) and create a new directory called `flux`.
28+
29+
```bash
30+
mkdir -p ~/.local/share/jupyter/kernels/flux
31+
```
32+
33+
If you're using Windows, the path will be different, such as `C:\Users\<YourUsername>\AppData\Roaming\jupyter\kernels`.
34+
35+
4. **Create the `kernel.json` File**:
36+
37+
Inside the new `flux` directory, create a file named `kernel.json`:
38+
39+
```bash
40+
nano ~/.local/share/jupyter/kernels/flux/kernel.json
41+
```
42+
43+
Paste the following content into the file:
44+
45+
```json
46+
{
47+
"argv": [
48+
"flux",
49+
"start",
50+
"/srv/conda/envs/notebook/bin/python",
51+
"-m",
52+
"ipykernel_launcher",
53+
"-f",
54+
"{connection_file}"
55+
],
56+
"display_name": "Flux",
57+
"language": "python",
58+
"metadata": {
59+
"debugger": true
60+
}
61+
}
62+
```
63+
64+
- **`argv`**: This array specifies the command to start the Jupyter kernel. It uses `flux start` to launch Python in the Flux environment.
65+
- **`display_name`**: The name displayed in Jupyter when selecting the kernel.
66+
- **`language`**: The programming language (`python`).
67+
68+
**Note**:
69+
70+
- Make sure to replace `"/srv/conda/envs/notebook/bin/python"` with the correct path to your Python executable. You can find this by running `which python` or `where python` in your terminal.
71+
- If you installed `flux` in a different environment, you have to write the absolute path to `flux` in the `argv` array.
72+
73+
#### Step 2: Restart Jupyter Notebook
74+
75+
1. **Restart the Jupyter Notebook Server**:
76+
77+
Close the current Jupyter Notebook server and restart it:
78+
79+
```bash
80+
jupyter notebook
81+
```
82+
83+
```bash
84+
jupyter lab
85+
```
86+
87+
Or simply restart your server.
88+
89+
2. **Select the Flux Kernel**:
90+
91+
When creating a new notebook or changing the kernel of an existing one, you should see an option for "Flux" in the list of available kernels. Select it to run your code with the Flux environment.
92+
93+
#### Step 3: Run Your Code with `FluxExecutor`
94+
95+
Now, your Jupyter environment is set up to use `flux-core`. You can run your code like this:
96+
97+
```python
98+
import flux.job
99+
100+
# Use FluxExecutor within the Flux kernel
101+
with flux.job.FluxExecutor() as flux_exe:
102+
print("FluxExecutor is running within the Jupyter Notebook")
103+
```

0 commit comments

Comments
 (0)