Skip to content

Commit

Permalink
migrate to jupyterlab (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 authored Jun 13, 2023
1 parent 923b868 commit ea7904f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ dependencies:
- fsspec
- geopandas
- joblib
- jupyterlab
- libnetcdf != 4.9.1
- matplotlib
- netCDF4
- notebook
- numpy
- pip
- plotly
Expand Down
8 changes: 4 additions & 4 deletions scripts/jupyter_server.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@


def get_jupyter_server_url(wd_path: pathlib.Path) -> Optional[urllib.parse.ParseResult]:
cmd = ["jupyter", "notebook", "list"]
cmd = ["jupyter", "lab", "list"]
proc = subprocess.run(cmd, capture_output=True, check=True, text=True)
for line in proc.stdout.splitlines()[1:]:
jupyter_url, jupyter_dir = line.split(" :: ")
jupyter_url, jupyter_dir = [segment.strip() for segment in line.split("::")]
if pathlib.Path(jupyter_dir) == wd_path:
return urllib.parse.urlparse(jupyter_url)
return None


def start_jupyter_server(wd_path: pathlib.Path) -> urllib.parse.ParseResult:
log = wd_path / "jupyter.log"
cmd = f"jupyter notebook --no-browser > {log!s} 2>&1 &"
cmd = f"jupyter lab --no-browser > {log!s} 2>&1 &"
subprocess.run(cmd, check=True, shell=True)
while True:
jupyter_url = get_jupyter_server_url(wd_path)
Expand All @@ -51,6 +51,6 @@ def start_jupyter_server(wd_path: pathlib.Path) -> urllib.parse.ParseResult:
http://localhost:5678/?{jupyter_url.query}
To stop the server use this command:
jupyter notebook stop {jupyter_url.netloc.split(":")[-1]}
jupyter lab stop {jupyter_url.netloc.split(":")[-1]}
"""
logging.info(msg)

0 comments on commit ea7904f

Please sign in to comment.