cloudos-cli 2.17.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudos_cli/__init__.py +11 -0
- cloudos_cli/__main__.py +1297 -0
- cloudos_cli/_version.py +1 -0
- cloudos_cli/clos.py +726 -0
- cloudos_cli/jobs/__init__.py +8 -0
- cloudos_cli/jobs/job.py +555 -0
- cloudos_cli/queue/__init__.py +8 -0
- cloudos_cli/queue/queue.py +139 -0
- cloudos_cli/utils/__init__.py +9 -0
- cloudos_cli/utils/errors.py +32 -0
- cloudos_cli/utils/requests.py +75 -0
- cloudos_cli-2.17.0.dist-info/LICENSE +674 -0
- cloudos_cli-2.17.0.dist-info/METADATA +1060 -0
- cloudos_cli-2.17.0.dist-info/RECORD +41 -0
- cloudos_cli-2.17.0.dist-info/WHEEL +5 -0
- cloudos_cli-2.17.0.dist-info/entry_points.txt +2 -0
- cloudos_cli-2.17.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/functions_for_pytest.py +7 -0
- tests/test_clos/__init__.py +0 -0
- tests/test_clos/test_create_cromwell_header.py +35 -0
- tests/test_clos/test_cromwell_switch.py +77 -0
- tests/test_clos/test_detect_workflow.py +47 -0
- tests/test_clos/test_get_cromwell_status.py +77 -0
- tests/test_clos/test_get_curated_workflow_list.py +72 -0
- tests/test_clos/test_get_job_list.py +79 -0
- tests/test_clos/test_get_job_status.py +75 -0
- tests/test_clos/test_get_project_list.py +74 -0
- tests/test_clos/test_get_user_info.py +68 -0
- tests/test_clos/test_get_workflow_list.py +87 -0
- tests/test_clos/test_is_module.py +48 -0
- tests/test_clos/test_process_job_list.py +74 -0
- tests/test_clos/test_process_project_list.py +36 -0
- tests/test_clos/test_process_workflow_list.py +36 -0
- tests/test_clos/test_wait_job_completion.py +40 -0
- tests/test_clos/test_workflow_import.py +77 -0
- tests/test_jobs/__init__.py +0 -0
- tests/test_jobs/test_convert_nextflow_to_json.py +104 -0
- tests/test_jobs/test_project_id.py +67 -0
- tests/test_jobs/test_send_job.py +84 -0
- tests/test_jobs/test_workflow_id.py +67 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""pytest is added for checking Job.workflow_id"""
|
|
2
|
+
from io import StringIO
|
|
3
|
+
import sys
|
|
4
|
+
import mock
|
|
5
|
+
import responses
|
|
6
|
+
from responses import matchers
|
|
7
|
+
from cloudos_cli.jobs import Job
|
|
8
|
+
from tests.functions_for_pytest import load_json_file
|
|
9
|
+
|
|
10
|
+
INPUT = "tests/test_data/send_job.json"
|
|
11
|
+
APIKEY = 'vnoiweur89u2ongs'
|
|
12
|
+
CLOUDOS_URL = 'http://cloudos.lifebit.ai'
|
|
13
|
+
WORKSPACE_ID = 'lv89ufc838sdig'
|
|
14
|
+
PROJECT_NAME = "lifebit-testing"
|
|
15
|
+
WORKFLOW_NAME = "nf-core-deepvariant"
|
|
16
|
+
INPUT_PROJECT = "tests/test_data/projects.json"
|
|
17
|
+
INPUT_WORKFLOW = "tests/test_data/workflows.json"
|
|
18
|
+
PAGE_SIZE = 10
|
|
19
|
+
PAGE = 1
|
|
20
|
+
ARCHIVED_STATUS = "false"
|
|
21
|
+
|
|
22
|
+
param_dict = {
|
|
23
|
+
"config": "cloudos_cli/examples/rnatoy.config"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@mock.patch('cloudos_cli.clos', mock.MagicMock())
|
|
28
|
+
@responses.activate
|
|
29
|
+
def test_send_job():
|
|
30
|
+
"""
|
|
31
|
+
Test 'send_job' to work as intended
|
|
32
|
+
API request is mocked and replicated with json files
|
|
33
|
+
"""
|
|
34
|
+
create_json_project = load_json_file(INPUT_PROJECT)
|
|
35
|
+
create_json_workflow = load_json_file(INPUT_WORKFLOW)
|
|
36
|
+
create_json = load_json_file(INPUT)
|
|
37
|
+
params_job = {"teamId": WORKSPACE_ID}
|
|
38
|
+
params_workflows = {
|
|
39
|
+
"teamId": WORKSPACE_ID,
|
|
40
|
+
"pageSize": PAGE_SIZE,
|
|
41
|
+
"page": PAGE,
|
|
42
|
+
"archived.status": ARCHIVED_STATUS}
|
|
43
|
+
header = {
|
|
44
|
+
"Content-type": "application/json",
|
|
45
|
+
"apikey": APIKEY
|
|
46
|
+
}
|
|
47
|
+
search_str = f"teamId={WORKSPACE_ID}"
|
|
48
|
+
search_str_workflows = f"teamId={WORKSPACE_ID}&pageSize={PAGE_SIZE}&page={PAGE}&archived.status={ARCHIVED_STATUS}"
|
|
49
|
+
# mock GET method with the .json
|
|
50
|
+
responses.add(
|
|
51
|
+
responses.POST,
|
|
52
|
+
url=f"{CLOUDOS_URL}/api/v1/jobs?{search_str}",
|
|
53
|
+
body=create_json,
|
|
54
|
+
headers=header,
|
|
55
|
+
match=[matchers.query_param_matcher(params_job)],
|
|
56
|
+
status=200)
|
|
57
|
+
responses.add(
|
|
58
|
+
responses.GET,
|
|
59
|
+
url=f"{CLOUDOS_URL}/api/v1/projects?{search_str}",
|
|
60
|
+
body=create_json_project,
|
|
61
|
+
headers=header,
|
|
62
|
+
match=[matchers.query_param_matcher(params_job)],
|
|
63
|
+
status=200)
|
|
64
|
+
responses.add(
|
|
65
|
+
responses.GET,
|
|
66
|
+
url=f"{CLOUDOS_URL}/api/v3/workflows?{search_str_workflows}",
|
|
67
|
+
body=create_json_workflow,
|
|
68
|
+
headers=header,
|
|
69
|
+
match=[matchers.query_param_matcher(params_workflows)],
|
|
70
|
+
status=200)
|
|
71
|
+
# start cloudOS service
|
|
72
|
+
job = Job(apikey=APIKEY,
|
|
73
|
+
cloudos_url=CLOUDOS_URL,
|
|
74
|
+
workspace_id=WORKSPACE_ID,
|
|
75
|
+
cromwell_token=None,
|
|
76
|
+
project_name=PROJECT_NAME,
|
|
77
|
+
workflow_name=WORKFLOW_NAME)
|
|
78
|
+
output = StringIO()
|
|
79
|
+
sys.stdout = output
|
|
80
|
+
job_json = job.send_job(param_dict["config"])
|
|
81
|
+
result_string = output.getvalue().rstrip()
|
|
82
|
+
|
|
83
|
+
assert isinstance(job_json, str)
|
|
84
|
+
assert "Job successfully launched to CloudOS, please check the following link:" in result_string
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""pytest is added for checking Job.workflow_id"""
|
|
2
|
+
import mock
|
|
3
|
+
import responses
|
|
4
|
+
from responses import matchers
|
|
5
|
+
from cloudos_cli.jobs import Job
|
|
6
|
+
from tests.functions_for_pytest import load_json_file
|
|
7
|
+
|
|
8
|
+
INPUT_PROJECT = "tests/test_data/projects.json"
|
|
9
|
+
INPUT_WORKFLOW = "tests/test_data/workflows.json"
|
|
10
|
+
APIKEY = 'vnoiweur89u2ongs'
|
|
11
|
+
CLOUDOS_URL = 'http://cloudos.lifebit.ai'
|
|
12
|
+
WORKSPACE_ID = 'lv89ufc838sdig'
|
|
13
|
+
PROJECT_NAME = "lifebit-testing"
|
|
14
|
+
WORKFLOW_NAME = "nf-core-deepvariant"
|
|
15
|
+
PAGE_SIZE = 10
|
|
16
|
+
PAGE = 1
|
|
17
|
+
ARCHIVED_STATUS = "false"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@mock.patch('cloudos_cli.clos', mock.MagicMock())
|
|
21
|
+
@responses.activate
|
|
22
|
+
def test_workflow_id():
|
|
23
|
+
"""
|
|
24
|
+
Test 'workflow_id' to work as intended
|
|
25
|
+
API request is mocked and replicated with json files
|
|
26
|
+
"""
|
|
27
|
+
create_json_project = load_json_file(INPUT_PROJECT)
|
|
28
|
+
create_json_workflow = load_json_file(INPUT_WORKFLOW)
|
|
29
|
+
params = {"teamId": WORKSPACE_ID}
|
|
30
|
+
params_workflows = {
|
|
31
|
+
"teamId": WORKSPACE_ID,
|
|
32
|
+
"pageSize": PAGE_SIZE,
|
|
33
|
+
"page": PAGE,
|
|
34
|
+
"archived.status": ARCHIVED_STATUS}
|
|
35
|
+
header = {
|
|
36
|
+
"Accept": "application/json, text/plain, */*",
|
|
37
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
38
|
+
"apikey": APIKEY
|
|
39
|
+
}
|
|
40
|
+
search_str = f"teamId={WORKSPACE_ID}"
|
|
41
|
+
search_str_workflows = f"teamId={WORKSPACE_ID}&pageSize={PAGE_SIZE}&page={PAGE}&archived.status={ARCHIVED_STATUS}"
|
|
42
|
+
# mock GET method with the .json
|
|
43
|
+
responses.add(
|
|
44
|
+
responses.GET,
|
|
45
|
+
url=f"{CLOUDOS_URL}/api/v1/projects?{search_str}",
|
|
46
|
+
body=create_json_project,
|
|
47
|
+
headers=header,
|
|
48
|
+
match=[matchers.query_param_matcher(params)],
|
|
49
|
+
status=200)
|
|
50
|
+
responses.add(
|
|
51
|
+
responses.GET,
|
|
52
|
+
url=f"{CLOUDOS_URL}/api/v3/workflows?{search_str_workflows}",
|
|
53
|
+
body=create_json_workflow,
|
|
54
|
+
headers=header,
|
|
55
|
+
match=[matchers.query_param_matcher(params_workflows)],
|
|
56
|
+
status=201)
|
|
57
|
+
# start cloudOS service
|
|
58
|
+
job = Job(apikey=APIKEY,
|
|
59
|
+
cloudos_url=CLOUDOS_URL,
|
|
60
|
+
workspace_id=WORKSPACE_ID,
|
|
61
|
+
cromwell_token=None,
|
|
62
|
+
project_name=PROJECT_NAME,
|
|
63
|
+
workflow_name=WORKFLOW_NAME)
|
|
64
|
+
# get mock response
|
|
65
|
+
wf_id = job.workflow_id
|
|
66
|
+
# check the response
|
|
67
|
+
assert wf_id == "111XXX111"
|