-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from michellab/feature-web
Feature web (a.k.a. BioSimSpace 2023.0.0) [ci skip]
- Loading branch information
Showing
167 changed files
with
5,047 additions
and
869 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
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,45 @@ | ||
|
||
# Script that collects as much as it can from a failed conda build so that it can | ||
# be stored as a GitHub Actions artifact for download and further debugging | ||
|
||
import os | ||
import sys | ||
import glob | ||
import tarfile | ||
|
||
if "BUILD_DIR" not in os.environ: | ||
try: | ||
os.environ["BUILD_DIR"] = sys.argv[1] | ||
except Exception: | ||
print("You need to supply BUILD_DIR") | ||
sys.exit(-1) | ||
|
||
build_dir = os.environ["BUILD_DIR"] | ||
|
||
# We want to bzip up the last 'sire-*' and all 'broken-*' directories in build_dir | ||
work_dirs = glob.glob(os.path.join(build_dir, "biosimspace_*", "work", "build")) | ||
broken_dirs = glob.glob(os.path.join(build_dir, "broke*")) | ||
|
||
if len(work_dirs) > 0: | ||
work_dirs = [work_dirs[-1]] | ||
|
||
zipdirs = work_dirs + broken_dirs | ||
|
||
output_filename = os.path.join(build_dir, "failed.tar.bz2") | ||
|
||
print(f"Zipping up {zipdirs} to {output_filename}") | ||
|
||
def filter_function(tarinfo): | ||
filename = tarinfo.name | ||
#print(filename) | ||
if filename.find('.git') != -1: | ||
#print("excluded!") | ||
return None | ||
else: | ||
return tarinfo | ||
|
||
with tarfile.open(output_filename, "w:bz2") as tar: | ||
for dir in zipdirs: | ||
tar.add(dir, arcname=os.path.basename(dir), filter=filter_function) | ||
|
||
print("Complete :-)") |
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,47 @@ | ||
|
||
|
||
def parse_requirements(filename): | ||
"""Parse the requirements and return (in conda notation) | ||
the requirements for this system | ||
""" | ||
try: | ||
from pip_requirements_parser import RequirementsFile | ||
except ImportError as e: | ||
print("\n\n[ERROR] ** You need to install pip-requirements-parser") | ||
print("Run `conda install pip-requirements-parser\n\n") | ||
raise e | ||
|
||
from pkg_resources import evaluate_marker | ||
|
||
reqs = RequirementsFile.from_file(filename).to_dict()["requirements"] | ||
|
||
deps = {} | ||
|
||
for req in reqs: | ||
name = req["name"] | ||
specifier = req["specifier"] | ||
marker = req["marker"] | ||
|
||
if len(specifier) == 0: | ||
specifier = "" | ||
else: | ||
specifier = specifier[0] | ||
|
||
if marker is not None: | ||
# check to see if this line fits this platform | ||
include = evaluate_marker(marker) | ||
else: | ||
include = True | ||
|
||
if include: | ||
deps[name] = specifier | ||
|
||
reqs = list(deps.keys()) | ||
reqs.sort() | ||
|
||
result = [] | ||
|
||
for req in reqs: | ||
result.append(f"{req}{deps[req]}") | ||
|
||
return result |
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,71 @@ | ||
|
||
import sys | ||
import os | ||
import subprocess | ||
|
||
script = os.path.abspath(sys.argv[0]) | ||
|
||
# we want to import the 'get_requirements' package from this directory | ||
sys.path.insert(0, os.path.dirname(script)) | ||
|
||
from parse_requirements import parse_requirements | ||
|
||
# go up one directories to get the source directory | ||
# (this script is in BioSimSpace/actions/) | ||
srcdir = os.path.dirname(os.path.dirname(script)) | ||
|
||
condadir = os.path.join(srcdir, "recipes", "biosimspace") | ||
|
||
print(f"conda recipe in {condadir}") | ||
|
||
# Store the name of the recipe and template YAML files. | ||
recipe = os.path.join(condadir, "meta.yaml") | ||
template = os.path.join(condadir, "template.yaml") | ||
|
||
# Now parse all of the requirements | ||
run_reqs = parse_requirements(os.path.join(srcdir, "requirements.txt")) | ||
print(run_reqs) | ||
build_reqs = parse_requirements(os.path.join(srcdir, "requirements_build.txt")) | ||
print(build_reqs) | ||
|
||
|
||
def run_cmd(cmd): | ||
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) | ||
return str(p.stdout.read().decode("utf-8")).lstrip().rstrip() | ||
|
||
gitdir = os.path.join(srcdir, ".git") | ||
|
||
# Get the BSS branch. | ||
branch = run_cmd(f"git --git-dir={gitdir} --work-tree={srcdir} rev-parse --abbrev-ref HEAD") | ||
print(branch) | ||
|
||
lines = open(template, "r").readlines() | ||
|
||
|
||
def dep_lines(deps): | ||
lines = [] | ||
|
||
for dep in deps: | ||
lines.append(f" - {dep}\n") | ||
|
||
return "".join(lines) | ||
|
||
|
||
run_reqs = dep_lines(run_reqs) | ||
|
||
if len(build_reqs) > 0: | ||
build_reqs = f" build:\n{dep_lines(build_reqs)}" | ||
else: | ||
build_reqs = "" | ||
|
||
|
||
with open(recipe, "w") as FILE: | ||
for line in lines: | ||
if line.find("BSS_BUILD_REQUIREMENTS") != -1: | ||
line = build_reqs | ||
elif line.find("BSS_RUN_REQUIREMENTS") != -1: | ||
line = run_reqs | ||
else: | ||
line = line.replace("BSS_BRANCH", branch) | ||
|
||
FILE.write(line) |
Oops, something went wrong.