Skip to content

Commit

Permalink
Merge pull request #57 from ksuderman/benchmark
Browse files Browse the repository at this point in the history
Benchmark
  • Loading branch information
ksuderman authored Dec 9, 2021
2 parents da98767 + 1a41d3d commit 7081ed0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
11 changes: 8 additions & 3 deletions abm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import sys
import os
import logging
from lib import common
# from lib import GALAXY_SERVER
import lib.common
from lib.common import parse_profile

# These imports are required because they need to be added to the symbol table
Expand Down Expand Up @@ -203,8 +204,12 @@ def entrypoint():
return

if profile is not None:
common.GALAXY_SERVER, common.API_KEY, common.KUBECONFIG = parse_profile(profile)
if common.GALAXY_SERVER is None:
# common.GALAXY_SERVER, common.API_KEY, common.KUBECONFIG = parse_profile(profile)
if not lib.common.set_active_profile(profile):
print(f"ERROR: Unable to set the active profile. No GALAXY_SERVER defined.")
return
if lib.GALAXY_SERVER is None:
print("ERROR: GALAXY_SERVER was not set in the profile.")
return
if command in all_commands:
subcommands = all_commands[command]
Expand Down
6 changes: 5 additions & 1 deletion lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import os, sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.path.dirname(os.path.realpath(__file__)))

# TODO: These should be encapsultated into a proper *context* type object.
global GALAXY_SERVER, API_KEY, KUBECONFIG
GALAXY_SERVER = API_KEY = KUBECONFIG = None
6 changes: 4 additions & 2 deletions lib/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import helm
import common
from lib import GALAXY_SERVER, API_KEY, KUBECONFIG
from common import connect, parse_profile, load_profiles
#from workflow import parse_workflow, find_workflow_id, find_dataset_id, Keys
import workflow
Expand Down Expand Up @@ -45,8 +46,9 @@ def run(args: list):
if cloud not in profiles:
print(f"WARNING: no profile for instance {cloud}")
continue
common.GALAXY_SERVER, common.API_KEY, common.KUBECONFIG = parse_profile(cloud)
if common.KUBECONFIG is None:
# GALAXY_SERVER, API_KEY, KUBECONFIG = parse_profile(cloud)
foo
if KUBECONFIG is None:
print(f"WARNGING: no kubeconfig for instance {cloud}")
continue
for job_conf in config['job_configs']:
Expand Down
27 changes: 16 additions & 11 deletions lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import yaml
import subprocess
import bioblend.galaxy
# from lib import GALAXY_SERVER, API_KEY, KUBECONFIG
import lib

# TODO: These should be encapsultated into a proper *context* type object.
GALAXY_SERVER = None
API_KEY = None
KUBECONFIG = None
# global GALAXY_SERVER, API_KEY, KUBECONFIG

PROFILE_SEARCH_PATH = ['~/.abm/profile.yml', '.abm-profile.yml']

Expand All @@ -23,27 +22,33 @@
"rna": []
}

# def init():
# # TODO: These should be encapsultated into a proper *context* type object.
# GALAXY_SERVER = None
# API_KEY = None
# KUBECONFIG = None


def connect():
"""
Create a connection to the Galaxy instance
:return: a GalaxyInstance object
"""
if GALAXY_SERVER is None:
if lib.GALAXY_SERVER is None:
print('ERROR: The Galaxy server URL has not been set. Please check your')
print(' configuration in ~/.abm/profile.yml and try again.')
sys.exit(1)
if API_KEY is None:
if lib.API_KEY is None:
print('ERROR: The Galaxy API key has not been set. Please check your')
print(' configuration in ~/.abm/profile.yml and try again.')
sys.exit(1)
return bioblend.galaxy.GalaxyInstance(url=GALAXY_SERVER, key=API_KEY)
return bioblend.galaxy.GalaxyInstance(url=lib.GALAXY_SERVER, key=lib.API_KEY)


def set_active_profile(profile_name: str):
GALAXY_SERVER, API_KEY, KUBECONFIG = parse_profile(profile_name)
return GALAXY_SERVER != None
lib.GALAXY_SERVER, lib.API_KEY, lib.KUBECONFIG = parse_profile(profile_name)
return lib.GALAXY_SERVER != None


def load_profiles():
Expand Down Expand Up @@ -89,8 +94,8 @@ def run(command, env:dict=None):
if env is not None:
for name,value in env.items():
os.environ[name] = value
if KUBECONFIG is not None:
os.environ['KUBECONFIG'] = KUBECONFIG
if lib.KUBECONFIG is not None:
os.environ['KUBECONFIG'] = lib.KUBECONFIG
result = subprocess.run(command.split(), capture_output=True, env=os.environ)
if result.returncode == 0:
raise RuntimeError(result.stdout.decode('utf-8').strip())
Expand Down
2 changes: 1 addition & 1 deletion lib/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .common import connect, GALAXY_SERVER
from common import connect
from pprint import pprint
import yaml

Expand Down
2 changes: 1 addition & 1 deletion lib/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import yaml

from lib.common import connect, parse_profile, GALAXY_SERVER
from lib.common import connect, parse_profile
from pprint import pprint

#
Expand Down
3 changes: 2 additions & 1 deletion lib/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pprint import pprint
from planemo.runnable import for_path
from planemo.galaxy.workflows import install_shed_repos

import lib
import common
from bioblend.galaxy import GalaxyInstance
from common import connect
Expand Down Expand Up @@ -310,6 +310,7 @@ def validate(args: list):
if not os.path.exists(workflow_path):
print(f'ERROR: can not find workflow configuration {workflow_path}')
return
print(f"Validating workflow on {lib.GALAXY_SERVER}")
workflows = parse_workflow(workflow_path)
gi = connect()
total_errors = 0
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
alias abm="python3 abm"
alias abm="python3 abm.py"
source .venv/bin/activate

0 comments on commit 7081ed0

Please sign in to comment.