diff --git a/deployments/biology/image/patches/ncbiquery.py b/deployments/biology/image/patches/ncbiquery.py index a0cb6a44b..5a2192d04 100644 --- a/deployments/biology/image/patches/ncbiquery.py +++ b/deployments/biology/image/patches/ncbiquery.py @@ -175,7 +175,7 @@ def get_fuzzy_name_translation(self, name, sim=0.9): result = _db.execute(cmd) try: taxid, spname, score = result.fetchone() - except: + except Exception: pass else: taxid = int(taxid) @@ -299,7 +299,7 @@ def get_name_translator(self, names): query = ','.join(['"%s"' %n for n in six.iterkeys(name2origname)]) cmd = 'select spname, taxid from species where spname IN (%s)' %query - result = self.db.execute('select spname, taxid from species where spname IN (%s)' %query) + result = self.db.execute(cmd) for sp, taxid in result.fetchall(): oname = name2origname[sp.lower()] name2id.setdefault(oname, []).append(taxid) @@ -395,18 +395,16 @@ def get_topology(self, taxids, intermediate_nodes=False, rank_limit=None, collap root_taxid = int(list(taxids)[0]) with open(self.dbfile+".traverse.pkl", "rb") as CACHED_TRAVERSE: prepostorder = pickle.load(CACHED_TRAVERSE) - descendants = {} - found = 0 nodes = {} - hit = 0 visited = set() start = prepostorder.index(root_taxid) try: - end = prepostorder.index(root_taxid, start+1) - subtree = prepostorder[start:end+1] + end = prepostorder.index(root_taxid, start+1) + subtree = prepostorder[start:end+1] except ValueError: # If root taxid is not found in postorder, must be a tip node - subtree = [root_taxid] + subtree = [root_taxid] + leaves = set([v for v, count in Counter(subtree).items() if count == 1]) nodes[root_taxid] = PhyloTree(name=str(root_taxid)) current_parent = nodes[root_taxid] @@ -663,7 +661,6 @@ def load_ncbi_tree_from_dump(tar): name2node = {} node2taxname = {} synonyms = set() - name2rank = {} node2common = {} print("Loading node names...") for line in tar.extractfile("names.dmp"): diff --git a/deployments/data101/image/environment.yml b/deployments/data101/image/environment.yml index 313b9c50b..7436db03a 100644 --- a/deployments/data101/image/environment.yml +++ b/deployments/data101/image/environment.yml @@ -108,3 +108,4 @@ dependencies: - git+https://github.com/shaneknapp/python-popularity-contest.git@add-error-handling # pulled in by ottr, if not pinned to 1.16.2, 1.16.3 causes DH-323 - jupytext==1.16.2 + - jupyterlab-a11y-checker==0.1.2 # Adding a11y-checker for Data 101 staff's exploration diff --git a/deployments/data8/image/ipython_config.py b/deployments/data8/image/ipython_config.py index ab5c5b8b6..a8774967b 100644 --- a/deployments/data8/image/ipython_config.py +++ b/deployments/data8/image/ipython_config.py @@ -1,3 +1,3 @@ # Disable history manager, we don't really use it # and by default it puts an sqlite file on NFS, which is not something we wanna do -c.HistoryManager.enabled = False +c.HistoryManager.enabled = False # noqa: F821 diff --git a/deployments/datahub/config/common.yaml b/deployments/datahub/config/common.yaml index 540b9e4a1..bc77e9c64 100644 --- a/deployments/datahub/config/common.yaml +++ b/deployments/datahub/config/common.yaml @@ -50,6 +50,20 @@ jupyterhub: - course::1535590::enrollment_type::teacher - course::1535590::enrollment_type::ta + # COMPSS 202, Summer 2024, https://github.com/berkeley-dsep-infra/datahub/issues/5861 + course-staff-1535811: + # description: Enable course staff to view and access servers. + # # this role provides permissions to... + scopes: + - admin-ui + - list:users!group=course::1535811 + - admin:servers!group=course::1535811 + - access:servers!group=course::1535811 + # # this role will be assigned to... + groups: + - course::1535811::enrollment_type::teacher + - course::1535811::enrollment_type::ta + nodeSelector: hub.jupyter.org/pool-name: core-pool-2024-05-08 initContainers: @@ -127,6 +141,7 @@ jupyterhub: stringData: | c.QtPDFExporter.enabled = False c.QtPNGExporter.enabled = False + c.WebPDFExporter.embed_images = True memory: guarantee: 512M limit: 1G diff --git a/deployments/edx/image/ipython_config.py b/deployments/edx/image/ipython_config.py index ab5c5b8b6..a8774967b 100644 --- a/deployments/edx/image/ipython_config.py +++ b/deployments/edx/image/ipython_config.py @@ -1,3 +1,3 @@ # Disable history manager, we don't really use it # and by default it puts an sqlite file on NFS, which is not something we wanna do -c.HistoryManager.enabled = False +c.HistoryManager.enabled = False # noqa: F821 diff --git a/images/node-placeholder-scaler/scaler/scaler.py b/images/node-placeholder-scaler/scaler/scaler.py index bd49bf9a9..7bb240d09 100755 --- a/images/node-placeholder-scaler/scaler/scaler.py +++ b/images/node-placeholder-scaler/scaler/scaler.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import logging -import datetime import argparse import tempfile import subprocess @@ -54,15 +53,16 @@ def get_replica_counts(events): pools_replica_config = None try: pools_replica_config = yaml.load(ev.description) - except: + except Exception as e: + logging.error(f"Caught unhandled exception parsing event description:\n{e}") logging.error(f"Error in parsing description of {_event_repr(ev)}") logging.error(f"{ev.description=}") pass if pools_replica_config is None: logging.error(f"No description in event {_event_repr(ev)}") continue - elif type(pools_replica_config) == str: - logging.error(f"Event description not parsed as dictionary.") + elif isinstance(pools_replica_config, str): + logging.error("Event description not parsed as dictionary.") logging.error(f"{ev.description=}") continue for pool_name, count in pools_replica_config.items(): diff --git a/scripts/delete-unused-users.py b/scripts/delete-unused-users.py index 0da572147..6922a7185 100755 --- a/scripts/delete-unused-users.py +++ b/scripts/delete-unused-users.py @@ -142,7 +142,7 @@ def main(args): and if so, delete them! """ if args.credentials and args.hub_url: - logger.error(f"Please use only one of --hub_url or --credentials options when executing the script.") + logger.error("Please use only one of --hub_url or --credentials options when executing the script.") raise if args.hub_url: diff --git a/scripts/git-pre-cloner.py b/scripts/git-pre-cloner.py index fc0f64eb4..6c13466dd 100644 --- a/scripts/git-pre-cloner.py +++ b/scripts/git-pre-cloner.py @@ -2,7 +2,6 @@ import argparse import os -import sys import string import subprocess @@ -27,6 +26,7 @@ def git_clone(): return out = subprocess.check_output(['git', 'clone', args.repo], cwd=local_repo).decode('utf-8') + return out def copy_repo(username): safe = safe_username(username) @@ -34,10 +34,14 @@ def copy_repo(username): source_dir = os.path.join(local_repo, repo_dirname) dest_dir = os.path.join(home_dir, repo_dirname) if os.path.exists(dest_dir): - if args.verbose: print('Skipping {}'.format(safe)) + if args.verbose: + print('Skipping {}'.format(safe)) else: - if args.verbose: print(safe) + if args.verbose: + print(safe) out = subprocess.check_output(['cp', '-a', source_dir, dest_dir]) + return out + return # main parser = argparse.ArgumentParser(description='Pre-clone course assets.') @@ -54,13 +58,16 @@ def copy_repo(username): if not os.path.exists(local_repo): os.mkdir(local_repo) -git_clone() +out = git_clone() +if args.verbose: + print(out) f = open(args.filename) line = f.readline() while line != '': email = line.strip() - if '@berkeley.edu' not in email: continue # just in case + if '@berkeley.edu' not in email: + continue # just in case username = email.split('@')[0] copy_repo(username) line = f.readline()