Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 5879, 5880, 5881 & 5883 to prod #5884

Merged
merged 9 commits into from
Jul 22, 2024
15 changes: 6 additions & 9 deletions deployments/biology/image/patches/ncbiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"):
Expand Down
1 change: 1 addition & 0 deletions deployments/data101/image/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion deployments/data8/image/ipython_config.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions deployments/datahub/config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -127,6 +141,7 @@ jupyterhub:
stringData: |
c.QtPDFExporter.enabled = False
c.QtPNGExporter.enabled = False
c.WebPDFExporter.embed_images = True
memory:
guarantee: 512M
limit: 1G
Expand Down
2 changes: 1 addition & 1 deletion deployments/edx/image/ipython_config.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions images/node-placeholder-scaler/scaler/scaler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
import logging
import datetime
import argparse
import tempfile
import subprocess
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion scripts/delete-unused-users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 12 additions & 5 deletions scripts/git-pre-cloner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import argparse
import os
import sys
import string
import subprocess

Expand All @@ -27,17 +26,22 @@ 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)
home_dir = home_directory(safe)
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.')
Expand All @@ -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()
Expand Down
Loading