Skip to content

Commit

Permalink
feat(rest): make details available for shared workflows (reanahub#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanRosendal committed Mar 20, 2024
1 parent 2fd5682 commit 96f3ac9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions reana_workflow_controller/rest/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def get_workflow_parameters(workflow_id_or_name): # noqa

try:
user_uuid = request.args["user"]
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid, True)

workflow_parameters = workflow.get_input_parameters()
return (
Expand Down Expand Up @@ -880,9 +880,13 @@ def get_workflow_diff(workflow_id_or_name_a, workflow_id_or_name_b): # noqa
context_lines = request.args.get("context_lines", 5)

workflow_a_exists = False
workflow_a = _get_workflow_with_uuid_or_name(workflow_id_or_name_a, user_uuid)
workflow_a = _get_workflow_with_uuid_or_name(
workflow_id_or_name_a, user_uuid, True
)
workflow_a_exists = True
workflow_b = _get_workflow_with_uuid_or_name(workflow_id_or_name_b, user_uuid)
workflow_b = _get_workflow_with_uuid_or_name(
workflow_id_or_name_b, user_uuid, True
)
if not workflow_id_or_name_a or not workflow_id_or_name_b:
raise ValueError("Workflow id or name is not supplied")
specification_diff = get_specification_diff(workflow_a, workflow_b)
Expand Down Expand Up @@ -1014,7 +1018,7 @@ def get_workflow_retention_rules(workflow_id_or_name: str, user: str):
}
"""
try:
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user, True)

rules = workflow.retention_rules.all()
response = {
Expand Down
4 changes: 2 additions & 2 deletions reana_workflow_controller/rest/workflows_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_workflow_logs(workflow_id_or_name, paginate=None, **kwargs): # noqa
try:
user_uuid = request.args["user"]

workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid, True)

steps = None
if request.is_json:
Expand Down Expand Up @@ -278,7 +278,7 @@ def get_workflow_status(workflow_id_or_name): # noqa

try:
user_uuid = request.args["user"]
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid, True)
workflow_logs = build_workflow_logs(workflow)

return (
Expand Down
4 changes: 2 additions & 2 deletions reana_workflow_controller/rest/workflows_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def download_file(workflow_id_or_name, file_name): # noqa
if not user:
return jsonify({"message": "User {} does not exist".format(user)}), 404

workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid, True)
workflow_name = workflow.get_full_workflow_name()

return download_files_recursive_wildcard(
Expand Down Expand Up @@ -474,7 +474,7 @@ def get_files(workflow_id_or_name, paginate=None): # noqa
if not user:
return jsonify({"message": "User {} does not exist".format(user)}), 404

workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid)
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, user_uuid, True)
file_name = request.args.get("file_name")
if search:
search = json.loads(search)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ def test_get_workflow_status_unauthorized(
content_type="application/json",
data=json.dumps(cwl_workflow_with_name),
)
assert res.status_code == 404
assert res.status_code == 500


def test_get_workflow_status_unknown_workflow(app, user0, cwl_workflow_with_name):
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def test_set_workflow_status_unauthorized(
query_string={"user": random_user_uuid, "status": payload},
content_type="application/json",
)
assert res.status_code == 404
assert res.status_code == 500


def test_set_workflow_status_unknown_workflow(
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def test_get_workflow_logs_unauthorized(
query_string={"user": random_user_uuid},
content_type="application/json",
)
assert res.status_code == 404
assert res.status_code == 500


def test_start_input_parameters(
Expand Down Expand Up @@ -1785,7 +1785,7 @@ def test_get_workflow_retention_rules_invalid_user(app, sample_serial_workflow_i
),
query_string={"user": uuid.uuid4()},
)
assert res.status_code == 404
assert res.status_code == 500


def test_share_workflow(
Expand Down

0 comments on commit 96f3ac9

Please sign in to comment.