Skip to content

Commit

Permalink
add secrets into cwl and yml
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Oct 31, 2024
1 parent 44df605 commit 3873675
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/galaxy/tool_util/cwl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def software_requirements(self) -> List:
def resource_requirements(self) -> List:
return self.hints_or_requirements_of_class("ResourceRequirement")

def secrets(self) -> List:
return self.hints_or_requirements_of_class("Secrets")


class CommandLineToolProxy(ToolProxy):
_class = "CommandLineTool"
Expand Down
9 changes: 6 additions & 3 deletions lib/galaxy/tool_util/deps/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,14 @@ def to_dict(self) -> Dict[str, Any]:
"required": self.required,
}

def from_dict(self, dict: Dict[str, Any]) -> "SecretsRequirement":
@classmethod
def from_dict(cls, dict: Dict[str, Any]) -> "SecretsRequirement":
type = dict["type"]
user_preferences_key = dict["user_preferences_key"]
inject_as_env = dict["inject_as_env"]
label = dict.get("label", "")
required = dict.get("required", False)
return SecretsRequirement(
return cls(
type=type,
user_preferences_key=user_preferences_key,
inject_as_env=inject_as_env,
Expand All @@ -358,11 +359,13 @@ def parse_requirements_from_lists(
software_requirements: List[Union[ToolRequirement, Dict[str, Any]]],
containers: Iterable[Dict[str, Any]],
resource_requirements: Iterable[Dict[str, Any]],
) -> Tuple[ToolRequirements, List[ContainerDescription], List[ResourceRequirement]]:
secrets: Iterable[Dict[str, Any]],
) -> Tuple[ToolRequirements, List[ContainerDescription], List[ResourceRequirement], List[SecretsRequirement]]:
return (
ToolRequirements.from_list(software_requirements),
[ContainerDescription.from_dict(c) for c in containers],
resource_requirements_from_list(resource_requirements),
[SecretsRequirement.from_dict(s) for s in secrets],
)


Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/tool_util/parser/cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ def parse_requirements_and_containers(self):

software_requirements = self.tool_proxy.software_requirements()
resource_requirements = self.tool_proxy.resource_requirements()
secrets = self.tool_proxy.secrets()
return requirements.parse_requirements_from_lists(
software_requirements=[{"name": r[0], "version": r[1], "type": "package"} for r in software_requirements],
containers=containers,
resource_requirements=resource_requirements,
secrets=secrets,
)

def parse_profile(self):
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/tool_util/parser/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def parse_requirements_and_containers(self):
software_requirements=[r for r in mixed_requirements if r.get("type") != "resource"],
containers=self.root_dict.get("containers", []),
resource_requirements=[r for r in mixed_requirements if r.get("type") == "resource"],
secrets=self.root_dict.get("secrets", []),
)

def parse_input_pages(self) -> PagesSource:
Expand Down

0 comments on commit 3873675

Please sign in to comment.