Skip to content

Commit

Permalink
WIP: landing library -> catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Sep 25, 2024
1 parent 0f871a4 commit 060a77c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
30 changes: 15 additions & 15 deletions lib/galaxy/tool_util/client/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
RANDOM_SECRET_LENGTH = 10


def load_default_library():
library_yaml = resource_string("galaxy.tool_util.client", "landing_library.sample.yml")
return yaml.safe_load(library_yaml)
def load_default_catalog():
catalog_yaml = resource_string("galaxy.tool_util.client", "landing_catalog.sample.yml")
return yaml.safe_load(catalog_yaml)


@dataclass
class Request:
template_id: str
library: str
catalog: str
client_secret: Optional[str]
galaxy_url: str

Expand All @@ -43,19 +43,19 @@ class Response:

def generate_claim_url(request: Request) -> Response:
template_id = request.template_id
library_path = request.library
catalog_path = request.catalog
galaxy_url = request.galaxy_url
client_secret = request.client_secret
if client_secret == "__GEN__":
client_secret = "".join(
random.choice(string.ascii_lowercase + string.digits) for _ in range(RANDOM_SECRET_LENGTH)
)
if library_path:
with open(library_path) as f:
library = yaml.safe_load(f)
if catalog_path:
with open(catalog_path) as f:
catalog = yaml.safe_load(f)
else:
library = load_default_library()
template = library[template_id]
catalog = load_default_catalog()
template = catalog[template_id]
template_type = "tool" if "tool_id" in template else "workflow"
if client_secret:
template["client_secret"] = client_secret
Expand Down Expand Up @@ -84,11 +84,11 @@ def arg_parser() -> argparse.ArgumentParser:
help="Galxy target for the landing request",
)
parser.add_argument(
"-l",
"--library",
dest="library",
"-c",
"--catalog",
dest="catalog",
default=None,
help="YAML library to load landing request templates from.",
help="YAML catalog to load landing request templates from.",
)
parser.add_argument(
"-s",
Expand All @@ -107,7 +107,7 @@ def main(argv=None) -> None:
args = arg_parser().parse_args(argv)
request = Request(
args.template_id,
args.library,
args.catalog,
args.secret,
args.galaxy_url,
)
Expand Down
21 changes: 21 additions & 0 deletions lib/galaxy/tool_util/client/landing_library.catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Catalog of artifacts that the landing script can generate landing URLs for against
# the target Galaxy.
simple_workflow:
# Encoded ID for a workflow to target - if workflow_target_type is stored_workflow this
# will always be the latest version of that workflow and stored workflow ID should be provided.
# If instead workflow_target_type is workflow - this is a particular version of a workflow and
# the workflow ID should be provided.
workflow_id: f2db41e1fa331b3e
workflow_target_type: stored_workflow
# request state provides prepopulated parameters for this workflow or stored workflow when the
# user navigates to the landing URL.
request_state:
myinput:
src: url
url: https://raw.githubusercontent.com/galaxyproject/galaxy/dev/test-data/1.bed
ext: txt
int_workflow:
workflow_id: f597429621d6eb2b
workflow_target_type: stored_workflow
request_state:
int_input: 8
13 changes: 0 additions & 13 deletions lib/galaxy/tool_util/client/landing_library.sample.yml

This file was deleted.

0 comments on commit 060a77c

Please sign in to comment.