Skip to content

Commit

Permalink
Only list active conda-envs for dask-gateway (#1162)
Browse files Browse the repository at this point in the history
* Only list available conda-envs

* Add QHUB_GH_BRANCH as env var to workflows

* Add QHUB_GH_BRANCH as env var to workflows

* Update gateway_config.py

* Pin Jupyterlab version

* Add jupyter_server dep

* Remove jupyter_server dep

* Avoid troublesome jupyter_server versions

* Fix

* Fix

Co-authored-by: Christopher Ostrouchov <[email protected]>
  • Loading branch information
iameskild and costrouc authored Mar 17, 2022
1 parent 3937daf commit 25d94e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion qhub/provider/cicd/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def gha_env_vars(config):
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
}

if os.environ.get("QHUB_GH_BRANCH"):
env_vars["QHUB_GH_BRANCH"] = "${{ secrets.QHUB_GH_BRANCH }}"

if config["provider"] == "aws":
env_vars["AWS_ACCESS_KEY_ID"] = "${{ secrets.AWS_ACCESS_KEY_ID }}"
env_vars["AWS_SECRET_ACCESS_KEY"] = "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
Expand Down Expand Up @@ -266,7 +269,7 @@ def gen_qhub_linter(config):
env_vars = {}
qhub_gh_branch = os.environ.get("QHUB_GH_BRANCH")
if qhub_gh_branch:
env_vars["QHUB_GH_BRANCH"] = qhub_gh_branch
env_vars["QHUB_GH_BRANCH"] = "${{ secrets.QHUB_GH_BRANCH }}"
else:
env_vars = None

Expand Down
1 change: 1 addition & 0 deletions qhub/template/image/jupyterlab/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- nb_conda_kernels
- ipython > 7
- jupyter-server-proxy
- "jupyter_server>=1.15.6 | <1.15"
- jupyterlab >=3
- jupyter_client
- jupyter_console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ async def authenticate(self, request):

# ==================== Profiles =======================
def get_packages(conda_prefix):
packages = set()
for filename in os.listdir(os.path.join(conda_prefix, "conda-meta")):
if filename.endswith(".json"):
with open(os.path.join(conda_prefix, "conda-meta", filename)) as f:
packages.add(json.load(f).get("name"))
return packages
try:
packages = set()
for filename in os.listdir(os.path.join(conda_prefix, "conda-meta")):
if filename.endswith(".json"):
with open(os.path.join(conda_prefix, "conda-meta", filename)) as f:
packages.add(json.load(f).get("name"))
return packages
except OSError as e:
import logging

logger = logging.getLogger()
logger.error(f"An issue with a conda environment was encountered.\n{e}")


def get_conda_prefixes(conda_store_mount):
Expand All @@ -105,7 +111,8 @@ def get_conda_prefixes(conda_store_mount):

def list_dask_environments(conda_store_mount):
for namespace, name, conda_prefix in get_conda_prefixes(conda_store_mount):
if {"dask", "distributed"} <= get_packages(conda_prefix):
packages = get_packages(conda_prefix)
if packages and {"dask", "distributed"} <= packages:
yield namespace, name, conda_prefix


Expand Down

0 comments on commit 25d94e5

Please sign in to comment.