Skip to content

Commit

Permalink
Merge 2257b8d into e603c11
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Oct 23, 2020
2 parents e603c11 + 2257b8d commit 35c51e0
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 37 deletions.
67 changes: 51 additions & 16 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,6 @@
"required": false,
"type": "array"
},
{
"description": "Size format, either 'b' (bytes) or 'k' (kilobytes).",
"in": "query",
"name": "block_size",
"required": false,
"type": "string"
},
{
"description": "Results page number (pagination).",
"in": "query",
Expand Down Expand Up @@ -687,31 +680,43 @@
"created": "2018-06-13T09:47:35.66097",
"id": "256b25f4-4cfb-4684-b7a8-73872ef455a1",
"name": "mytest.1",
"size": "10M",
"size": {
"human_readable": "10 MB",
"raw": 10490000
},
"status": "running",
"user": "00000000-0000-0000-0000-000000000000"
},
{
"created": "2018-06-13T09:47:35.66097",
"id": "3c9b117c-d40a-49e3-a6de-5f89fcada5a3",
"name": "mytest.2",
"size": "12M",
"size": {
"human_readable": "12 MB",
"raw": 12580000
},
"status": "finished",
"user": "00000000-0000-0000-0000-000000000000"
},
{
"created": "2018-06-13T09:47:35.66097",
"id": "72e3ee4f-9cd3-4dc7-906c-24511d9f5ee3",
"name": "mytest.3",
"size": "180K",
"size": {
"human_readable": "180 KB",
"raw": 184320
},
"status": "created",
"user": "00000000-0000-0000-0000-000000000000"
},
{
"created": "2018-06-13T09:47:35.66097",
"id": "c4c0a1a6-beef-46c7-be04-bf4b3beca5a1",
"name": "mytest.4",
"size": "1G",
"size": {
"human_readable": "1 GB",
"raw": 1074000000
},
"status": "created",
"user": "00000000-0000-0000-0000-000000000000"
}
Expand All @@ -735,7 +740,15 @@
"type": "object"
},
"size": {
"type": "string"
"properties": {
"human_readable": {
"type": "string"
},
"raw": {
"type": "number"
}
},
"type": "object"
},
"status": {
"type": "string"
Expand Down Expand Up @@ -1192,11 +1205,17 @@
"disk_usage_info": [
{
"name": "file1.txt",
"size": "12KB"
"size": {
"human_readable": "12 MB",
"raw": 12580000
}
},
{
"name": "plot.png",
"size": "100KB"
"size": {
"human_readable": "100 KB",
"raw": 184320
}
}
],
"workflow_id": "256b25f4-4cfb-4684-b7a8-73872ef455a1",
Expand All @@ -1212,7 +1231,15 @@
"type": "string"
},
"size": {
"type": "string"
"properties": {
"human_readable": {
"type": "string"
},
"raw": {
"type": "number"
}
},
"type": "object"
}
},
"type": "object"
Expand Down Expand Up @@ -2038,7 +2065,15 @@
"type": "string"
},
"size": {
"type": "integer"
"properties": {
"human_readable": {
"type": "string"
},
"raw": {
"type": "number"
}
},
"type": "object"
}
},
"type": "object"
Expand Down
65 changes: 45 additions & 20 deletions reana_server/rest/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ def get_workflows(**kwargs): # noqa
type: array
items:
type: string
- name: block_size
in: query
description: Size format, either 'b' (bytes) or 'k' (kilobytes).
required: false
type: string
- name: page
in: query
description: Results page number (pagination).
Expand Down Expand Up @@ -133,7 +128,12 @@ def get_workflows(**kwargs): # noqa
status:
type: string
size:
type: string
type: object
properties:
raw:
type: number
human_readable:
type: string
user:
type: string
created:
Expand All @@ -147,31 +147,43 @@ def get_workflows(**kwargs): # noqa
"id": "256b25f4-4cfb-4684-b7a8-73872ef455a1",
"name": "mytest.1",
"status": "running",
"size": "10M",
"size":{
"raw": 10490000,
"human_readable": "10 MB"
},
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
},
{
"id": "3c9b117c-d40a-49e3-a6de-5f89fcada5a3",
"name": "mytest.2",
"status": "finished",
"size": "12M",
"size":{
"raw": 12580000,
"human_readable": "12 MB"
},
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
},
{
"id": "72e3ee4f-9cd3-4dc7-906c-24511d9f5ee3",
"name": "mytest.3",
"status": "created",
"size": "180K",
"size":{
"raw": 184320,
"human_readable": "180 KB"
},
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
},
{
"id": "c4c0a1a6-beef-46c7-be04-bf4b3beca5a1",
"name": "mytest.4",
"status": "created",
"size": "1G",
"size": {
"raw": 1074000000,
"human_readable": "1 GB"
},
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
}
Expand Down Expand Up @@ -217,15 +229,13 @@ def get_workflows(**kwargs): # noqa
sort = request.args.get("sort", "desc")
status = request.args.getlist("status")
verbose = json.loads(request.args.get("verbose", "false").lower())
block_size = request.args.get("block_size")
response, http_response = current_rwc_api_client.api.get_workflows(
user=str(user.id_),
type=type_,
search=search,
sort=sort,
status=status or None,
verbose=bool(verbose),
block_size=block_size,
**kwargs,
).result()

Expand Down Expand Up @@ -1461,7 +1471,12 @@ def get_files(workflow_id_or_name, **kwargs): # noqa
last-modified:
type: string
size:
type: integer
type: object
properties:
raw:
type: number
human_readable:
type: string
400:
description: >-
Request failed. The incoming payload seems malformed.
Expand Down Expand Up @@ -2155,16 +2170,29 @@ def get_workflow_disk_usage(workflow_id_or_name): # noqa
name:
type: string
size:
type: string
type: object
properties:
raw:
type: number
human_readable:
type: string
examples:
application/json:
{
"workflow_id": "256b25f4-4cfb-4684-b7a8-73872ef455a1",
"workflow_name": "mytest.1",
"disk_usage_info": [{'name': 'file1.txt',
'size': '12KB'},
'size': {
'raw': 12580000,
'human_readable': '12 MB'
}
},
{'name': 'plot.png',
'size': '100KB'}]
'size': {
'raw': 184320,
'human_readable': '100 KB'
}
}]
}
400:
description: >-
Expand Down Expand Up @@ -2208,10 +2236,7 @@ def get_workflow_disk_usage(workflow_id_or_name): # noqa
raise ValueError("workflow_id_or_name is not supplied")
workflow = _get_workflow_with_uuid_or_name(workflow_id_or_name, str(user.id_))
summarize = bool(parameters.get("summarize", False))
block_size = parameters.get("block_size")
disk_usage_info = workflow.get_workspace_disk_usage(
summarize=summarize, block_size=block_size
)
disk_usage_info = workflow.get_workspace_disk_usage(summarize=summarize)
response = {
"workflow_id": workflow.id_,
"workflow_name": workflow.name,
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_openapi_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def build_openapi_spec(publish):
title=package,
version=ver,
info=dict(description=desc),
plugins=("apispec.ext.flask", "apispec.ext.marshmallow"),
plugins=("apispec.ext.flask",),
)

# Add marshmallow schemas to the specification here
Expand Down

0 comments on commit 35c51e0

Please sign in to comment.