-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
William Strecker-Kellogg
committed
May 27, 2021
1 parent
2c30244
commit c54a3e8
Showing
7 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Map "English Location Name" -> "Path" of virtualenv where jupyterlab lives | ||
locations: | ||
USATLAS: /cvmfs/atlas.sdcc.bnl.gov/jupyter/venv/notebook | ||
sPHENIX: /cvmfs/sphenix.sdcc.bnl.gov/foo | ||
PHENIX: /cvmfs/phenix.sdcc.bnl.gov/bar | ||
Default Condor: /cvmfs/sdcc.bnl.gov/jupyter/virtualenv/labenv | ||
Default HPC: /u0b/software/jupyter/virtenvs/labenv3/ | ||
CFN: /hpcgpfs01/software/jupyter/what | ||
|
||
# Map GID -> list of jupyterlab locations available | ||
groups: | ||
rhphenix: | ||
- PHENIX | ||
- sPHENIX | ||
sphenix: | ||
- sPHENIX | ||
usatlas: | ||
- USATLAS | ||
rhstaff: | ||
- USATLAS | ||
all: | ||
- Default Condor | ||
- Default HPC | ||
- CFN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import os | ||
|
||
from tornado.log import app_log | ||
from ruamel.yaml import YAML | ||
from .utils import get_all_groupnames | ||
|
||
|
||
def get_lab_locations(user, cfg="../conf/lab-locations.yml"): | ||
cfgpath = os.path.join(os.path.dirname(__file__), cfg) | ||
|
||
yaml = YAML(typ='safe') | ||
with open(cfgpath) as fp: | ||
data = yaml.load(fp) | ||
locations = data['locations'] | ||
group_map = data['groups'] | ||
|
||
available_labs = set() | ||
|
||
for group in get_all_groupnames(user): | ||
if group in group_map: | ||
for lab in group_map[group]: | ||
available_labs.add(lab) | ||
|
||
return [(x, locations[x]) for x in group_map['all'] + list(available_labs)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pwd | ||
import grp | ||
import os | ||
|
||
|
||
def primary_group(user): | ||
gid = pwd.getpwnam(user).pw_gid | ||
return grp.getgrgid(gid).gr_name | ||
|
||
|
||
def get_all_groupnames(user): | ||
gids = [x for x in os.getgrouplist(user, 0) if x > 0] | ||
return [grp.getgrgid(gid).gr_name for gid in gids] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters