-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow admins to import tools/workflows from paths.
- Loading branch information
Showing
10 changed files
with
122 additions
and
23 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,39 @@ | ||
"""Utilities for loading tools and workflows from paths for admin user requests.""" | ||
|
||
from gxformat2.converter import ordered_load | ||
|
||
from galaxy import exceptions | ||
|
||
|
||
def artifact_class(trans, as_dict): | ||
object_id = as_dict.get("object_id", None) | ||
if as_dict.get("src", None) == "from_path": | ||
if trans and not trans.user_is_admin: | ||
raise exceptions.AdminRequiredException() | ||
|
||
workflow_path = as_dict.get("path") | ||
with open(workflow_path, "r") as f: | ||
as_dict = ordered_load(f) | ||
|
||
artifact_class = as_dict.get("class", None) | ||
if artifact_class is None and "$graph" in as_dict: | ||
object_id = object_id or "main" | ||
graph = as_dict["$graph"] | ||
target_object = None | ||
if isinstance(graph, dict): | ||
target_object = graph.get(object_id) | ||
else: | ||
for item in graph: | ||
found_id = item.get("id") | ||
if found_id == object_id or found_id == "#" + object_id: | ||
target_object = item | ||
|
||
if target_object and target_object.get("class"): | ||
artifact_class = target_object["class"] | ||
|
||
return artifact_class, as_dict, object_id | ||
|
||
|
||
__all__ = ( | ||
'artifact_class', | ||
) |
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
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,12 @@ | ||
{ | ||
"name": "Minimal Tool", | ||
"class": "GalaxyTool", | ||
"version": "1.0.0", | ||
"command": "echo 'Hello World 2' > $output1", | ||
"inputs": [], | ||
"outputs": { | ||
"output1": { | ||
"format": 'txt' | ||
} | ||
} | ||
} |
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