Skip to content

Commit

Permalink
catch workflowhub error
Browse files Browse the repository at this point in the history
  • Loading branch information
paulzierep committed Nov 5, 2024
1 parent 4297e77 commit f80b83b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ To make a test run of the tool to check its functionalities follow [Usage](#Usag
1. Workflow extraction

```bash
$ bash bin/extract_all_workflows.sh test
$ bash sources/bin/extract_all_workflows.sh test
```

2. Workflow filtering

```bash
$ bash bin/get_community_workflowss.sh test
$ bash sources/bin/get_community_workflows.sh test
```

# Galaxy Labs framework
Expand Down
13 changes: 10 additions & 3 deletions sources/bin/extract_galaxy_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ def add_workflows_from_workflowhub(self) -> None:
f"https://workflowhub.eu{wf['links']['self']}",
header,
)
wf = Workflow()
wf.init_from_search(wf=wfhub_wf, source="WorkflowHub", tools=self.tools)
self.workflows.append(wf)
if wfhub_wf:
wf = Workflow()
wf.init_from_search(wf=wfhub_wf, source="WorkflowHub", tools=self.tools)
self.workflows.append(wf)
print(len(self.workflows))

def add_workflows_from_a_server(self, server: str) -> None:
Expand All @@ -170,6 +171,12 @@ def add_workflows_from_a_server(self, server: str) -> None:
f"{server}/api/workflows/",
header,
)

# test max 50 wfs
if self.test:
if len(server_wfs) > 50:
server_wfs = server_wfs[:50]

count = 0
for wf in server_wfs:
if wf["published"] and wf["importable"] and not wf["deleted"] and not wf["hidden"]:
Expand Down
14 changes: 11 additions & 3 deletions sources/bin/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ def get_request_json(url: str, headers: dict) -> dict:
:param url: galaxy tool id
"""
r = requests.get(url, auth=None, headers=headers)
r.raise_for_status()
return r.json()

try:
r = requests.get(url, auth=None, headers=headers)
r.raise_for_status() # Optional: Raises an HTTPError if the response was an unsuccessful status code
except ConnectionError as e:
raise ConnectionError("Connection aborted: Remote end closed connection without response") from e
except requests.exceptions.RequestException as e:
# This will handle other possible errors (e.g., timeout, HTTPError)
raise SystemExit(e)
else:
return r.json()


def format_date(date: str) -> str:
Expand Down

0 comments on commit f80b83b

Please sign in to comment.