Skip to content

Commit

Permalink
Merge bf95002 into 1b6f4b5
Browse files Browse the repository at this point in the history
  • Loading branch information
roksys committed Dec 4, 2018
2 parents 1b6f4b5 + bf95002 commit 6b1a5bf
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 9 deletions.
108 changes: 107 additions & 1 deletion reana_commons/openapi_specifications/reana_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,108 @@
"summary": "Creates a new workflow based on a REANA specification file."
}
},
"/api/workflows/{workflow_id_or_name_a}/diff/{workflow_id_or_name_b}": {
"get": {
"description": "This resource shows the differences between the assets of two workflows. Resource is expecting two workflow UUIDs or names.",
"operationId": "get_workflow_diff",
"parameters": [
{
"description": "Required. Analysis UUID or name of the first workflow.",
"in": "path",
"name": "workflow_id_or_name_a",
"required": true,
"type": "string"
},
{
"description": "Required. Analysis UUID or name of the second workflow.",
"in": "path",
"name": "workflow_id_or_name_b",
"required": true,
"type": "string"
},
{
"default": false,
"description": "Optional flag. If set, file contents are examined.",
"in": "query",
"name": "brief",
"required": false,
"type": "boolean"
},
{
"default": "5",
"description": "Optional parameter. Sets number of context lines for workspace diff output.",
"in": "query",
"name": "context_lines",
"required": false,
"type": "string"
},
{
"description": "Required. The API access_token of workflow owner.",
"in": "query",
"name": "access_token",
"required": true,
"type": "string"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Request succeeded. Info about a workflow, including the status is returned.",
"examples": {
"application/json": {
"reana_specification": [
"- nevents: 100000\n+ nevents: 200000"
],
"workspace_listing": {
"Only in workspace a: code": null
}
}
},
"schema": {
"properties": {
"reana_specification": {
"type": "string"
},
"workspace_listing": {
"type": "string"
}
},
"type": "object"
}
},
"400": {
"description": "Request failed. The incoming payload seems malformed.",
"examples": {
"application/json": {
"message": "Malformed request."
}
}
},
"403": {
"description": "Request failed. User is not allowed to access workflow.",
"examples": {
"application/json": {
"message": "User 00000000-0000-0000-0000-000000000000 is not allowed to access workflow 256b25f4-4cfb-4684-b7a8-73872ef455a1"
}
}
},
"404": {
"description": "Request failed. Either user or workflow does not exist.",
"examples": {
"application/json": {
"message": "Workflow 256b25f4-4cfb-4684-b7a8-73872ef455a1 does not exist."
}
}
},
"500": {
"description": "Request failed. Internal controller error."
}
},
"summary": "Get diff between two workflows."
}
},
"/api/workflows/{workflow_id_or_name}/logs": {
"get": {
"description": "This resource reports the status of a workflow. Resource is expecting a workflow UUID.",
Expand Down Expand Up @@ -520,7 +622,8 @@
"inputfile": "data/names.txt",
"outputfile": "results/greetings.txt",
"sleeptime": 2
}
},
"type": "serial"
}
},
"schema": {
Expand All @@ -533,6 +636,9 @@
},
"parameters": {
"type": "object"
},
"type": {
"type": "string"
}
},
"type": "object"
Expand Down
113 changes: 112 additions & 1 deletion reana_commons/openapi_specifications/reana_workflow_controller.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,108 @@
"summary": "Create workflow and its workspace."
}
},
"/api/workflows/{workflow_id_or_name_a}/diff/{workflow_id_or_name_b}": {
"get": {
"description": "This resource shows the differences between the assets of two workflows. Resource is expecting two workflow UUIDs or names.",
"operationId": "get_workflow_diff",
"parameters": [
{
"description": "Required. UUID of workflow owner.",
"in": "query",
"name": "user",
"required": true,
"type": "string"
},
{
"description": "Required. Analysis UUID or name of the first workflow.",
"in": "path",
"name": "workflow_id_or_name_a",
"required": true,
"type": "string"
},
{
"description": "Required. Analysis UUID or name of the second workflow.",
"in": "path",
"name": "workflow_id_or_name_b",
"required": true,
"type": "string"
},
{
"default": false,
"description": "Optional flag. If set, file contents are examined.",
"in": "query",
"name": "brief",
"required": false,
"type": "boolean"
},
{
"default": "5",
"description": "Optional parameter. Sets number of context lines for workspace diff output.",
"in": "query",
"name": "context_lines",
"required": false,
"type": "string"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Request succeeded. Info about a workflow, including the status is returned.",
"examples": {
"application/json": {
"reana_specification": [
"- nevents: 100000\n+ nevents: 200000"
],
"workspace_listing": {
"Only in workspace a: code": null
}
}
},
"schema": {
"properties": {
"reana_specification": {
"type": "string"
},
"workspace_listing": {
"type": "string"
}
},
"type": "object"
}
},
"400": {
"description": "Request failed. The incoming payload seems malformed.",
"examples": {
"application/json": {
"message": "Malformed request."
}
}
},
"403": {
"description": "Request failed. User is not allowed to access workflow.",
"examples": {
"application/json": {
"message": "User 00000000-0000-0000-0000-000000000000 is not allowed to access workflow 256b25f4-4cfb-4684-b7a8-73872ef455a1"
}
}
},
"404": {
"description": "Request failed. Either user or workflow does not exist.",
"examples": {
"application/json": {
"message": "Workflow 256b25f4-4cfb-4684-b7a8-73872ef455a1 does not exist."
}
}
},
"500": {
"description": "Request failed. Internal controller error."
}
},
"summary": "Get diff between two workflows."
}
},
"/api/workflows/{workflow_id_or_name}/logs": {
"get": {
"description": "This resource is expecting a workflow UUID and a filename to return its outputs.",
Expand Down Expand Up @@ -374,7 +476,8 @@
"inputfile": "data/names.txt",
"outputfile": "results/greetings.txt",
"sleeptime": 2
}
},
"type": "serial"
}
},
"schema": {
Expand All @@ -387,6 +490,9 @@
},
"parameters": {
"type": "object"
},
"type": {
"type": "string"
}
},
"type": "object"
Expand Down Expand Up @@ -535,6 +641,11 @@
},
{
"description": "Required. New status.",
"enum": [
"start",
"stop",
"deleted"
],
"in": "query",
"name": "status",
"required": true,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'pytest-cache>=1.0',
'pytest-cov>=1.8.0',
'pytest-pep8>=1.0.6',
'pytest-reana>=0.5.0.dev20181119',
'pytest-reana>=0.5.0.dev20181203',
'pytest>=3.8'
]

Expand Down
14 changes: 8 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ def test_calculate_hash_of_dir(sample_workflow_workspace):
"""Test calculate_hash_of_dir."""
non_existing_dir_hash = calculate_hash_of_dir('a/b/c')
assert non_existing_dir_hash == -1
dir_hash = calculate_hash_of_dir(sample_workflow_workspace)
sample_workflow_workspace_path = next(sample_workflow_workspace('sample'))
dir_hash = calculate_hash_of_dir(sample_workflow_workspace_path)
assert dir_hash == '8d287a3e2240b1762862d485a424363c'
include_only_path = os.path.join(sample_workflow_workspace,
include_only_path = os.path.join(sample_workflow_workspace_path,
'code', 'worldpopulation.ipynb')
hash_of_single_file = calculate_hash_of_dir(sample_workflow_workspace,
hash_of_single_file = calculate_hash_of_dir(sample_workflow_workspace_path,
[include_only_path])
assert hash_of_single_file == '18ce945e21ab4db472525abe1e0f8080'
empty_dir_hash = calculate_hash_of_dir(sample_workflow_workspace,
empty_dir_hash = calculate_hash_of_dir(sample_workflow_workspace_path,
[])
md5_hash = md5()
assert empty_dir_hash == md5_hash.hexdigest()
Expand All @@ -60,7 +61,8 @@ def test_calculate_job_input_hash():

def test_calculate_file_access_time(sample_workflow_workspace):
"""Test calculate_file_access_time."""
access_times = calculate_file_access_time(sample_workflow_workspace)
all_file_paths = list(Path(sample_workflow_workspace).rglob("*.*"))
sample_workflow_workspace_path = next(sample_workflow_workspace('sample'))
access_times = calculate_file_access_time(sample_workflow_workspace_path)
all_file_paths = list(Path(sample_workflow_workspace_path).rglob("*.*"))
for file_path in all_file_paths:
assert str(file_path) in access_times

0 comments on commit 6b1a5bf

Please sign in to comment.