geoseeq 0.6.15.dev1__py3-none-any.whl → 0.7.1__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.
- geoseeq/cli/download.py +2 -2
- geoseeq/cli/main.py +1 -1
- geoseeq/cli/upload/__init__.py +4 -3
- geoseeq/cli/upload/upload_advanced.py +230 -0
- geoseeq/cli/upload/upload_reads.py +14 -5
- geoseeq/constants.py +4 -1
- geoseeq/dashboard/dashboard.py +103 -0
- geoseeq/file_system/filesystem_download.py +434 -0
- geoseeq/file_system/main.py +122 -0
- geoseeq/id_constructors/from_ids.py +20 -14
- geoseeq/id_constructors/utils.py +17 -0
- geoseeq/plotting/README.md +4 -0
- geoseeq/upload_download_manager.py +16 -6
- geoseeq/vc/README.md +48 -0
- {geoseeq-0.6.15.dev1.dist-info → geoseeq-0.7.1.dist-info}/METADATA +8 -10
- {geoseeq-0.6.15.dev1.dist-info → geoseeq-0.7.1.dist-info}/RECORD +20 -18
- {geoseeq-0.6.15.dev1.dist-info → geoseeq-0.7.1.dist-info}/WHEEL +1 -2
- geoseeq-0.6.15.dev1.dist-info/top_level.txt +0 -2
- tests/test_api_client.py +0 -283
- tests/test_plotting.py +0 -29
- /tests/__init__.py → /geoseeq/contrib/ncbi/README.md +0 -0
- {geoseeq-0.6.15.dev1.dist-info → geoseeq-0.7.1.dist-info}/entry_points.txt +0 -0
- {geoseeq-0.6.15.dev1.dist-info → geoseeq-0.7.1.dist-info/licenses}/LICENSE +0 -0
@@ -77,8 +77,17 @@ class GeoSeeqUploadManager:
|
|
77
77
|
self.chunk_size_mb = chunk_size_mb
|
78
78
|
self.use_atomic_upload = use_atomic_upload
|
79
79
|
|
80
|
-
def add_result_file(self, result_file, local_path):
|
81
|
-
|
80
|
+
def add_result_file(self, result_file, local_path, link_type=None):
|
81
|
+
"""Add a result file to be uploaded or linked.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
result_file: A ResultFile object to upload to or link
|
85
|
+
local_path: Path to local file or URL to link
|
86
|
+
link_type: One of 'upload', 's3', 'ftp', 'azure', 'sra', 'http'
|
87
|
+
"""
|
88
|
+
if link_type is None:
|
89
|
+
link_type = self.link_type
|
90
|
+
self._result_files.append((result_file, local_path, link_type))
|
82
91
|
|
83
92
|
def add_local_file_to_result_folder(self, result_folder, local_path, geoseeq_file_name=None):
|
84
93
|
if not geoseeq_file_name:
|
@@ -96,19 +105,20 @@ class GeoSeeqUploadManager:
|
|
96
105
|
|
97
106
|
def get_preview_string(self):
|
98
107
|
out = ["Upload Preview:"]
|
99
|
-
for result_file, local_path in self._result_files:
|
100
|
-
|
108
|
+
for result_file, local_path, link_type in self._result_files:
|
109
|
+
action = "link" if link_type != 'upload' else "upload"
|
110
|
+
out.append(f"{local_path} -> {result_file} ({action})")
|
101
111
|
return "\n".join(out)
|
102
112
|
|
103
113
|
def upload_files(self):
|
104
114
|
upload_args = [(
|
105
115
|
result_file, local_path,
|
106
116
|
self.session, self.progress_tracker_factory(local_path),
|
107
|
-
|
117
|
+
link_type, self.overwrite, self.log_level,
|
108
118
|
self.n_parallel_uploads > 1, self.use_cache, self.no_new_versions,
|
109
119
|
self.threads_per_upload, self.num_retries, self.ignore_errors,
|
110
120
|
self.chunk_size_mb, self.use_atomic_upload
|
111
|
-
) for result_file, local_path in self._result_files
|
121
|
+
) for result_file, local_path, link_type in self._result_files
|
112
122
|
]
|
113
123
|
out = []
|
114
124
|
if self.n_parallel_uploads == 1:
|
geoseeq/vc/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# GeoSeeq Version Control
|
2
|
+
|
3
|
+
GeoSeeq VC is a toolkit that makes it easy to use geoseeq with version control systems like `git`.
|
4
|
+
|
5
|
+
Most of the files stored on GeoSeeq are too large to version control directly. This package creates lightweight stub files that record a files location and checksum. This package also contains tools to download files, and check that local files match those stored on the server. The stub files are small enough to version control directly.
|
6
|
+
|
7
|
+
## CLI
|
8
|
+
|
9
|
+
You can clone a project or sample from GeoSeeq. You will need to get the `brn` number from the project or sample then run these commands from your CLI
|
10
|
+
|
11
|
+
```
|
12
|
+
geoseeq-api vc clone brn:gsr1:project:bed763fb-f6b8-4739-8320-95c06d68f442 # creates a directory tree with stub files
|
13
|
+
geoseeq-api vc download # downloads the files that the stubs link to
|
14
|
+
geoseeq-api vc status # checks that the local files match the files on GeoSeeq
|
15
|
+
```
|
16
|
+
|
17
|
+
If you are using git you probably want to add files from geoseeq to your `.gitignore`
|
18
|
+
|
19
|
+
```
|
20
|
+
geoseeq-api vc list >> .gitignore
|
21
|
+
```
|
22
|
+
|
23
|
+
## Shared Cache
|
24
|
+
|
25
|
+
To avoid downloading or storing the same file multiple times users can specify a cache by setting the `GEOSEEQ_VC_CACHE_DIR` envvar to an absolute filepath. When set geoseeq will download files to a location in the cahce directory and create symlinks to those files.
|
26
|
+
|
27
|
+
## Stub Files
|
28
|
+
|
29
|
+
GeoSeeq interfaces with version control by creating small stub files that represent a larger file (AKA result field) stored on GeoSeeq. This package can be used to download those files and validate that the checksum of local files matches them. Since these files are small they can be easily stored with a version control system while the larger files can be ignored.
|
30
|
+
|
31
|
+
The stub files are JSON and have the following structure:
|
32
|
+
|
33
|
+
```
|
34
|
+
{
|
35
|
+
"__schema_version__": "v0",
|
36
|
+
"brn": "brn:<instance name>:result_field:<uuid>", # optional if stub is new and parent_info is set
|
37
|
+
"checksum": {
|
38
|
+
"value": "<value>",
|
39
|
+
"method": "md5",
|
40
|
+
},
|
41
|
+
"local_path": "<filename>", # a filepath relative to the stub file
|
42
|
+
"parent_info": { # optional if brn is set
|
43
|
+
"parent_obj_brn": "brn:<brn info>",
|
44
|
+
"result_module_name": <string>,
|
45
|
+
"result_module_replicate": <string>,
|
46
|
+
} # NB if brn and parent_info are both set but disagree `brn` is correct
|
47
|
+
}
|
48
|
+
```
|
@@ -1,23 +1,21 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: geoseeq
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.1
|
4
4
|
Summary: GeoSeeq command line tools and python API
|
5
|
-
Author: David C. Danko
|
6
|
-
Author-email: "David C. Danko" <dcdanko@biotia.io>
|
7
5
|
Project-URL: Homepage, https://github.com/biotia/geoseeq_api_client
|
8
6
|
Project-URL: Issues, https://github.com/biotia/geoseeq_api_client/issues
|
9
|
-
|
7
|
+
Author-email: "David C. Danko" <dcdanko@biotia.io>
|
8
|
+
License-File: LICENSE
|
10
9
|
Classifier: License :: OSI Approved :: MIT License
|
11
10
|
Classifier: Operating System :: OS Independent
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
12
|
Requires-Python: >=3.8
|
13
|
-
|
14
|
-
License-File: LICENSE
|
15
|
-
Requires-Dist: requests
|
13
|
+
Requires-Dist: biopython
|
16
14
|
Requires-Dist: click
|
17
15
|
Requires-Dist: pandas
|
18
|
-
Requires-Dist:
|
16
|
+
Requires-Dist: requests
|
19
17
|
Requires-Dist: tqdm
|
20
|
-
|
18
|
+
Description-Content-Type: text/markdown
|
21
19
|
|
22
20
|
# Geoseeq API Client
|
23
21
|
|
@@ -2,7 +2,7 @@ geoseeq/__init__.py,sha256=YqYqeHbqjgWI5OBIxkPXNvLISOjVWaNwVFy6AGJ7uwc,982
|
|
2
2
|
geoseeq/app.py,sha256=Y6d1UzxFLfE3RNccATbFCVi6kH3eFmzwoUbeR2Ry09A,2387
|
3
3
|
geoseeq/blob_constructors.py,sha256=AkWpDQY0EdGMxF1p6eRspyHKubcUdiW4it-_Q7S2QWk,188
|
4
4
|
geoseeq/bulk_creators.py,sha256=pdn-Dv7yv5SFv-PfDuQbuOnw2W4-BfIfRJVRAhM8U6s,2115
|
5
|
-
geoseeq/constants.py,sha256=
|
5
|
+
geoseeq/constants.py,sha256=KmWH3gwHLd3toTWLWSViV_1eAYzPOPZ5bv6INpgwzQI,665
|
6
6
|
geoseeq/file_system_cache.py,sha256=HzVZWtwLD2fjWWSo_UfWmGeBltm9He4lP_OqzKwNGWg,4138
|
7
7
|
geoseeq/knex.py,sha256=zcjafsmUn9SC3LlRnvvaXpr-pHYZ0IXk7LpzuUoE3MI,8312
|
8
8
|
geoseeq/organization.py,sha256=bJkYL8_D-k6IYAaii2ZbxjwYnXy6lvu6iLXscxKlA3w,2542
|
@@ -13,7 +13,7 @@ geoseeq/sample.py,sha256=HAfMiDPHp1UJgIA2lI6oGnNit4YKyj7nx9X07CCN98U,8316
|
|
13
13
|
geoseeq/search.py,sha256=gawad6Cx5FxJBPlYkXWb-UKAO-UC0_yhvyU9Ca1kaNI,3388
|
14
14
|
geoseeq/smart_table.py,sha256=rihMsFUIn-vn4w6ukVZTHI9bjDSEr8xHExBfX8mwCHM,6169
|
15
15
|
geoseeq/smart_tree.py,sha256=bSjDlwmOuNXutYJhytA1RovwRCHV6ZxXXJPiIGFhPaA,1825
|
16
|
-
geoseeq/upload_download_manager.py,sha256=
|
16
|
+
geoseeq/upload_download_manager.py,sha256=DxzwhkpuzuXTQt28ORULspDi2rzXqqIHqROEAs99SxQ,9849
|
17
17
|
geoseeq/user.py,sha256=tol8i1UGLRrbMw5jeJDnna1ikRgrCDd50Jxz0a1lSgg,690
|
18
18
|
geoseeq/utils.py,sha256=ZXpWb2MetUIeLrExiXb7IaOXYrW1pvrdP3o0KWzbwCs,4035
|
19
19
|
geoseeq/work_orders.py,sha256=5uLVVfdKE8qh4gGaHkdBpXJGRTujuSg59knWCqEET4A,8071
|
@@ -21,11 +21,11 @@ geoseeq/cli/__init__.py,sha256=4WnK87K5seRK3SGJAxNWnQTqyg5uBhdhrOrzB1D4b3M,24
|
|
21
21
|
geoseeq/cli/constants.py,sha256=Do5AUf9lMO9_P8KpFJ3XwwFBAWsxSjZ6sx9_QEGyC_c,176
|
22
22
|
geoseeq/cli/copy.py,sha256=02U9kdrAIbbM8MlRMLL6p-LMYFSuRObE3h5jyvcL__M,2275
|
23
23
|
geoseeq/cli/detail.py,sha256=q8Suu-j2k18knfSVFG-SWWGNsKM-n8y9RMA3LcIIi9Y,4132
|
24
|
-
geoseeq/cli/download.py,sha256=
|
24
|
+
geoseeq/cli/download.py,sha256=Znjuc9IFOcIa5_Od9mFXHJdYAJtgw9Bc_wPPcOVXn7s,21298
|
25
25
|
geoseeq/cli/fastq_utils.py,sha256=-bmeQLaiMBm57zWOF0R5OlWTU0_3sh1JBC1RYw2BOFM,3083
|
26
26
|
geoseeq/cli/find_grn.py,sha256=oMDxkzGQBQb2_cCuvmwoeHOsFHqyO9RLeJzrB6bAe5M,439
|
27
27
|
geoseeq/cli/get_eula.py,sha256=79mbUwyiF7O1r0g6UTxG9kJGQEqKuH805E6eLkPC6Y4,997
|
28
|
-
geoseeq/cli/main.py,sha256=
|
28
|
+
geoseeq/cli/main.py,sha256=jN3ar-CL5glFnlJhelXliESoP_W2QMrVKkHPQtvhU54,3982
|
29
29
|
geoseeq/cli/manage.py,sha256=wGXAcVaXqE5JQEU8Jh6OlHr02nB396bpS_SFcOZdrEo,5929
|
30
30
|
geoseeq/cli/progress_bar.py,sha256=p1Xl01nkYxSBZCB30ue2verIIi22W93m3ZAMAxipD0g,738
|
31
31
|
geoseeq/cli/project.py,sha256=V5SdXm2Hwo2lxrkpwRDedw-mAE4XnM2uwT-Gj1D90VQ,3030
|
@@ -41,23 +41,28 @@ geoseeq/cli/shared_params/config.py,sha256=HQ0xQh_jdt3EKI5VXYqQXzo-s8Rm6YlziMyVX
|
|
41
41
|
geoseeq/cli/shared_params/id_handlers.py,sha256=KtzflnplYVkXsyqI5Ej6r-_BwQnuXVHPr7JcYumTKNc,10700
|
42
42
|
geoseeq/cli/shared_params/obj_getters.py,sha256=ZSkt6LnDkVFlNVYKgLrjzg60-6BthZMr3eeD3HNqzac,2741
|
43
43
|
geoseeq/cli/shared_params/opts_and_args.py,sha256=_DcJ-TqgrbBaeDd-kuHEx2gLZPQN6EHZYWh8Ag-d8Vg,2091
|
44
|
-
geoseeq/cli/upload/__init__.py,sha256=
|
44
|
+
geoseeq/cli/upload/__init__.py,sha256=tRrljqG7uBM6zVBKpDw1zevHz6Vy418HuIYZKwByyWg,862
|
45
45
|
geoseeq/cli/upload/upload.py,sha256=U9w18sG6dZ0uJoAMcQDLdrEtgmRaSaPS7-8KM5LkVd4,14220
|
46
|
-
geoseeq/cli/upload/upload_advanced.py,sha256=
|
47
|
-
geoseeq/cli/upload/upload_reads.py,sha256=
|
46
|
+
geoseeq/cli/upload/upload_advanced.py,sha256=1pjtbe8EidIo4eR1_oVD00rPCTxYj8CRqB8D9buA62M,12432
|
47
|
+
geoseeq/cli/upload/upload_reads.py,sha256=dZK_Mh3a3NdC4zVB4Yyfz-NViCK9_rROQbmLWTrh8Pc,11642
|
48
48
|
geoseeq/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
|
+
geoseeq/contrib/ncbi/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
50
|
geoseeq/contrib/ncbi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
51
|
geoseeq/contrib/ncbi/api.py,sha256=WQeLoGA_-Zha-QeSO8_i7HpvXyD8UkV0qc5okm11KiA,1056
|
51
52
|
geoseeq/contrib/ncbi/bioproject.py,sha256=_oThTd_iLDOC8cLOlJKAatSr362OBYZCEV3YrqodhFg,4341
|
52
53
|
geoseeq/contrib/ncbi/cli.py,sha256=j9zEcaZPTryK3a4xluRxigcJKDhRpRxbp3KZSx-Bfhk,2400
|
53
54
|
geoseeq/contrib/ncbi/setup_logging.py,sha256=Tp1bY1U0f-o739aHpvVYriG2qdd1lFvCYBXZeXQgt-w,175
|
55
|
+
geoseeq/dashboard/dashboard.py,sha256=HOUJoQcFGLc3JL5UVIYETq6CkQEMP2I4WaPr2u9YV3Q,3297
|
56
|
+
geoseeq/file_system/filesystem_download.py,sha256=8bcnxjWltekmCvb5N0b1guBIjLp4-CL2VtsEok-snv4,16963
|
57
|
+
geoseeq/file_system/main.py,sha256=4HgYGq7WhlF96JlVIf16iFBTDujlBpxImmtoh4VCzDA,3627
|
54
58
|
geoseeq/id_constructors/__init__.py,sha256=w5E0PNQ9UuAxBeZbDI7KBnUoERd85gGz3nScz45bd2o,126
|
55
59
|
geoseeq/id_constructors/from_blobs.py,sha256=wZp6P6m7X0lhZAQxorHKJQn1CTBvKyfANzu2VFexp44,6315
|
56
|
-
geoseeq/id_constructors/from_ids.py,sha256=
|
60
|
+
geoseeq/id_constructors/from_ids.py,sha256=SRylajToFdnRON5EhPIvcAi64XuIzseaasZlOooqTpg,3984
|
57
61
|
geoseeq/id_constructors/from_names.py,sha256=RqgFjDsAwQcidMkZwX7oB00OvBAKTiilHYetTPogJ40,4174
|
58
62
|
geoseeq/id_constructors/from_uuids.py,sha256=loqTeZqDZuvfVVHpS7m-Y_spNaY3h9VRjt0wDiMxHbs,3522
|
59
63
|
geoseeq/id_constructors/resolvers.py,sha256=8hp5xJSCoZrAXtMT54Hp4okt63l909XqJU3IQx-VCgc,2676
|
60
|
-
geoseeq/id_constructors/utils.py,sha256=
|
64
|
+
geoseeq/id_constructors/utils.py,sha256=Up_vXoZDwa2mJGllJ6CmcbaOGUvA-sM0gMmFnXK8wn4,1255
|
65
|
+
geoseeq/plotting/README.md,sha256=qlPnEzJWVxBeLvgyFXIN2du_-6GprvX8lRk4ROw6aMs,82
|
61
66
|
geoseeq/plotting/__init__.py,sha256=RkGoXxgu7jEfK0B7NmdalPS2AbU7I7dZwDbi4rn9CKM,154
|
62
67
|
geoseeq/plotting/constants.py,sha256=CGUlm8WAFG3YRKdicc9Rcy5hFxUdUm2RgK0iXZWLuX8,285
|
63
68
|
geoseeq/plotting/highcharts.py,sha256=AGzdW4VSUsL_rfEI-RiVbbtaTLFMARvzLzVUDrKTlnU,4096
|
@@ -77,6 +82,7 @@ geoseeq/result/resumable_download_tracker.py,sha256=YEzqHBBnE7L3XokTvlTAhHZ8TcDT
|
|
77
82
|
geoseeq/result/resumable_upload_tracker.py,sha256=2aI09gYz2yw63jEXqs8lmCRKQ79TIc3YuPETvP0Jeek,3811
|
78
83
|
geoseeq/result/smart_objects.py,sha256=-krK9h9HcznIglf189uPghOidF_BzOeSxmBWxrtFFo8,1991
|
79
84
|
geoseeq/result/utils.py,sha256=C-CxGzB3WddlnRiqFSkrY78I_m0yFgNqsTBRzGU-y8Q,2772
|
85
|
+
geoseeq/vc/README.md,sha256=igLGXl1jpp2A_tTfPutspTejwE1lkObeCsSvCYPBqOM,2316
|
80
86
|
geoseeq/vc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
87
|
geoseeq/vc/checksum.py,sha256=y8rh1asUZNbE_NLiFO0-9hImLNiTOc2YXQBRKORWK7k,710
|
82
88
|
geoseeq/vc/cli.py,sha256=rUspr6FUJiUWIVMvf-pmyC5psKfufN45alk8392fAfA,2803
|
@@ -86,12 +92,8 @@ geoseeq/vc/vc_cache.py,sha256=P4LXTbq2zOIv1OhP7Iw5MmypR2vXuy29Pq5K6gRvi-M,730
|
|
86
92
|
geoseeq/vc/vc_dir.py,sha256=A9CLTh2wWCRzZjiLyqXD1vhtsWZGD3OjaMT5KqlfAXI,457
|
87
93
|
geoseeq/vc/vc_sample.py,sha256=qZeioWydXvfu4rGMs20nICfNcp46y_XkND-bHdV6P5M,3850
|
88
94
|
geoseeq/vc/vc_stub.py,sha256=IQr8dI0zsWKVAeY_5ybDD6n49_3othcgfHS3P0O9tuY,3110
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
geoseeq-0.
|
93
|
-
geoseeq-0.
|
94
|
-
geoseeq-0.6.15.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
95
|
-
geoseeq-0.6.15.dev1.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
|
96
|
-
geoseeq-0.6.15.dev1.dist-info/top_level.txt,sha256=zZk7mmeaqAYqFJG8nq2DTgSQPbflRjJwkDIhNURPDEU,14
|
97
|
-
geoseeq-0.6.15.dev1.dist-info/RECORD,,
|
95
|
+
geoseeq-0.7.1.dist-info/METADATA,sha256=7muy1ekQlBoXXfeEAz6NeuvXHgNttqHKJkCVSIqxdIU,4892
|
96
|
+
geoseeq-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
97
|
+
geoseeq-0.7.1.dist-info/entry_points.txt,sha256=yF-6KDM8zXib4Al0qn49TX-qM7PUkWUIcYtsgt36rjM,45
|
98
|
+
geoseeq-0.7.1.dist-info/licenses/LICENSE,sha256=IuhIl1XCxXLPLJT_coN1CNqQU4Khlq7x4IdW7ioOJD8,1067
|
99
|
+
geoseeq-0.7.1.dist-info/RECORD,,
|
tests/test_api_client.py
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
"""Test suite for experimental functions."""
|
2
|
-
import random
|
3
|
-
import sys
|
4
|
-
from os import environ
|
5
|
-
from unittest import TestCase, skip
|
6
|
-
|
7
|
-
from geoseeq import (
|
8
|
-
Knex,
|
9
|
-
Organization,
|
10
|
-
GeoseeqOtherError,
|
11
|
-
GeoseeqNotFoundError,
|
12
|
-
)
|
13
|
-
from requests.exceptions import ConnectionError
|
14
|
-
|
15
|
-
ENDPOINT = environ.get("GEOSEEQ_API_TESTING_ENDPOINT", "http://127.0.0.1:8000")
|
16
|
-
TOKEN = environ.get("GEOSEEQ_API_TOKEN", "<no_token>")
|
17
|
-
|
18
|
-
|
19
|
-
def random_str(len=12):
|
20
|
-
"""Return a random alphanumeric string of length `len`."""
|
21
|
-
out = random.choices("abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRTUVWXYZ0123456789", k=len)
|
22
|
-
return "".join(out)
|
23
|
-
|
24
|
-
|
25
|
-
class TestGeoseeqApiClient(TestCase):
|
26
|
-
"""Test suite for packet building."""
|
27
|
-
|
28
|
-
def setUp(self):
|
29
|
-
self.knex = Knex(ENDPOINT)
|
30
|
-
# Creates a test user and an API token for the user in database. Returns the token.
|
31
|
-
if TOKEN == "<no_token>":
|
32
|
-
try:
|
33
|
-
api_token = self.knex.post("/users/test-user",
|
34
|
-
json={"email": f"clitestuser_{random_str()}@gmail.com"})
|
35
|
-
except GeoseeqOtherError:
|
36
|
-
print(f"Could not create test user on \"{ENDPOINT}\". If you are running this test suite "\
|
37
|
-
"against a live server, please set the GEOSEEQ_API_TOKEN environment variable to a "\
|
38
|
-
"valid API token.",
|
39
|
-
file=sys.stderr)
|
40
|
-
raise
|
41
|
-
except ConnectionError:
|
42
|
-
print(f"Could not connect to GeoSeeq Server at \"{ENDPOINT}\".",
|
43
|
-
file=sys.stderr)
|
44
|
-
raise
|
45
|
-
self.knex.add_api_token(api_token)
|
46
|
-
else:
|
47
|
-
self.knex.add_api_token(TOKEN)
|
48
|
-
try:
|
49
|
-
me = self.knex.get("/users/me") # Test that the token is valid
|
50
|
-
self.username = me["name"]
|
51
|
-
self.org_name = f"API_TEST_ORG 1 {self.username}"
|
52
|
-
except GeoseeqNotFoundError:
|
53
|
-
print(f"Could not connect to GeoSeeq Server at \"{ENDPOINT}\" with the provided token. "\
|
54
|
-
"Is it possible that you set thd testing endpoint to a front end url instead of "\
|
55
|
-
"the corresponding backend url?",
|
56
|
-
file=sys.stderr)
|
57
|
-
raise
|
58
|
-
|
59
|
-
def test_create_org(self):
|
60
|
-
"""Test that we can create an org."""
|
61
|
-
org = Organization(self.knex, self.org_name)
|
62
|
-
org.idem()
|
63
|
-
self.assertTrue(org.uuid)
|
64
|
-
|
65
|
-
|
66
|
-
def test_create_project(self):
|
67
|
-
"""Test that we can create a project."""
|
68
|
-
key = random_str()
|
69
|
-
org = Organization(self.knex, self.org_name)
|
70
|
-
|
71
|
-
proj = org.project(f"my_client_test_project {key}")
|
72
|
-
proj.create()
|
73
|
-
self.assertTrue(org.uuid)
|
74
|
-
self.assertTrue(proj.uuid)
|
75
|
-
|
76
|
-
def test_create_project_result_folder(self):
|
77
|
-
"""Test that we can create a result folder in a project."""
|
78
|
-
key = random_str()
|
79
|
-
org = Organization(self.knex, self.org_name)
|
80
|
-
proj = org.project(f"my_client_test_proj {key}")
|
81
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
82
|
-
result_folder = proj.result_folder(f"my_client_test_module_name") # no {key} necessary
|
83
|
-
result_folder.create()
|
84
|
-
self.assertTrue(org.uuid)
|
85
|
-
self.assertTrue(proj.uuid)
|
86
|
-
self.assertTrue(result_folder.uuid)
|
87
|
-
|
88
|
-
def test_create_project_result_file(self):
|
89
|
-
"""Test that we can create a result file in a project."""
|
90
|
-
key = random_str()
|
91
|
-
org = Organization(self.knex, self.org_name)
|
92
|
-
proj = org.project(f"my_client_test_proj {key}")
|
93
|
-
result_folder = proj.result_folder(f"my_client_test_module_name") # no {key} necessary
|
94
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
95
|
-
result_file = result_folder.result_file("my_client_test_field_name", {"foo": "bar"})
|
96
|
-
result_file.create()
|
97
|
-
self.assertTrue(org.uuid)
|
98
|
-
self.assertTrue(proj.uuid)
|
99
|
-
self.assertTrue(result_folder.uuid)
|
100
|
-
self.assertTrue(result_file.uuid)
|
101
|
-
|
102
|
-
def test_create_sample(self):
|
103
|
-
"""Test that we can create a sample."""
|
104
|
-
key = random_str()
|
105
|
-
org = Organization(self.knex, self.org_name)
|
106
|
-
proj = org.project(f"my_client_test_proj {key}")
|
107
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
108
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
109
|
-
samp.create()
|
110
|
-
self.assertTrue(org.uuid)
|
111
|
-
self.assertTrue(proj.uuid)
|
112
|
-
self.assertTrue(samp.uuid)
|
113
|
-
|
114
|
-
def test_add_sample(self):
|
115
|
-
"""Test that we can create a sample and add it to a different project."""
|
116
|
-
key = random_str()
|
117
|
-
org = Organization(self.knex, self.org_name)
|
118
|
-
proj1 = org.project(f"my_client_test_proj1 {key}")
|
119
|
-
samp = proj1.sample(f"my_client_test_sample {key}").create()
|
120
|
-
|
121
|
-
proj2 = org.project(f"my_client_test_proj2 {key}").create()
|
122
|
-
proj2.add_sample(samp).save()
|
123
|
-
self.assertIn(samp.uuid, {samp.uuid for samp in proj2.get_samples()})
|
124
|
-
|
125
|
-
def test_get_samples_project(self):
|
126
|
-
"""Test that we can get the samples in a project."""
|
127
|
-
key = random_str()
|
128
|
-
org = Organization(self.knex, self.org_name)
|
129
|
-
proj = org.project(f"my_client_test_proj {key}")
|
130
|
-
samp_names = [f"my_client_test_sample_{i} {key}" for i in range(10)]
|
131
|
-
for samp_name in samp_names:
|
132
|
-
proj.sample(samp_name).create()
|
133
|
-
retrieved_proj = org.project(f"my_client_test_proj {key}").get()
|
134
|
-
retrieved_names = set()
|
135
|
-
for samp in retrieved_proj.get_samples():
|
136
|
-
retrieved_names.add(samp.name)
|
137
|
-
self.assertTrue(samp.uuid)
|
138
|
-
for samp_name in samp_names:
|
139
|
-
self.assertIn(samp_name, retrieved_names)
|
140
|
-
|
141
|
-
def test_get_result_folders_in_project(self):
|
142
|
-
"""Test that we can get the result folders in a project."""
|
143
|
-
key = random_str()
|
144
|
-
org = Organization(self.knex, self.org_name)
|
145
|
-
proj = org.project(f"my_client_test_proj {key}")
|
146
|
-
result_names = [("my_client_test_module", f"replicate_{i}") for i in range(10)]
|
147
|
-
for module_name, replicate in result_names:
|
148
|
-
proj.result_folder(module_name, replicate=replicate).create()
|
149
|
-
retrieved_proj = org.project(f"my_client_test_proj {key}").get()
|
150
|
-
retrieved_names = set()
|
151
|
-
for result in retrieved_proj.get_result_folders():
|
152
|
-
retrieved_names.add((result.module_name, result.replicate))
|
153
|
-
self.assertTrue(result.uuid)
|
154
|
-
for result_name_rep in result_names:
|
155
|
-
self.assertIn(result_name_rep, retrieved_names)
|
156
|
-
|
157
|
-
def test_get_result_folders_in_sample(self):
|
158
|
-
"""Test that we can get the result folders in a sample."""
|
159
|
-
key = random_str()
|
160
|
-
org = Organization(self.knex, self.org_name)
|
161
|
-
proj = org.project(f"my_client_test_proj {key}")
|
162
|
-
samp = proj.sample(f"my_client_test_sample {key}").create()
|
163
|
-
result_names = [("my_client_test_module", f"replicate_{i}") for i in range(10)]
|
164
|
-
for module_name, replicate in result_names:
|
165
|
-
samp.result_folder(module_name, replicate=replicate).create()
|
166
|
-
retrieved = proj.sample(f"my_client_test_sample {key}").get()
|
167
|
-
retrieved_names = set()
|
168
|
-
for result in retrieved.get_result_folders():
|
169
|
-
retrieved_names.add((result.module_name, result.replicate))
|
170
|
-
self.assertTrue(result.uuid)
|
171
|
-
for result_name_rep in result_names:
|
172
|
-
self.assertIn(result_name_rep, retrieved_names)
|
173
|
-
|
174
|
-
def test_get_result_files(self):
|
175
|
-
"""Test that we can get the files in a result folder."""
|
176
|
-
key = random_str()
|
177
|
-
org = Organization(self.knex, self.org_name)
|
178
|
-
proj = org.project(f"my_client_test_proj {key}")
|
179
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
180
|
-
result_folder = samp.result_folder("my_client_test_module").create()
|
181
|
-
self.assertTrue(proj.uuid)
|
182
|
-
|
183
|
-
field_names = [f"field_{i}" for i in range(10)]
|
184
|
-
for field_name in field_names:
|
185
|
-
result_folder.field(field_name).create()
|
186
|
-
|
187
|
-
retrieved = samp.result_folder("my_client_test_module").get()
|
188
|
-
retrieved_names = set()
|
189
|
-
for result in retrieved.get_fields():
|
190
|
-
retrieved_names.add(result.name)
|
191
|
-
self.assertTrue(result.uuid)
|
192
|
-
for result_name_rep in field_names:
|
193
|
-
self.assertIn(result_name_rep, retrieved_names)
|
194
|
-
|
195
|
-
def test_modify_sample(self):
|
196
|
-
"""Test that we can modify a sample after creation"""
|
197
|
-
key = random_str()
|
198
|
-
org = Organization(self.knex, self.org_name)
|
199
|
-
proj = org.project(f"my_client_test_proj {key}")
|
200
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
201
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
202
|
-
samp.create()
|
203
|
-
self.assertTrue(samp.uuid)
|
204
|
-
self.assertTrue(samp._already_fetched)
|
205
|
-
self.assertFalse(samp._modified)
|
206
|
-
samp.metadata = {f"metadata_{key}": "some_new_metadata"}
|
207
|
-
self.assertTrue(samp._modified)
|
208
|
-
samp.save()
|
209
|
-
self.assertTrue(samp._already_fetched)
|
210
|
-
self.assertFalse(samp._modified)
|
211
|
-
retrieved = proj.sample(f"my_client_test_sample {key}").get()
|
212
|
-
self.assertIn(f"metadata_{key}", retrieved.metadata)
|
213
|
-
|
214
|
-
def test_create_sample_result_folder(self):
|
215
|
-
"""Test that we can create a result folder in a sample."""
|
216
|
-
key = random_str()
|
217
|
-
org = Organization(self.knex, self.org_name)
|
218
|
-
proj = org.project(f"my_client_test_proj {key}")
|
219
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
220
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
221
|
-
result_folder = samp.result_folder(f"my_client_test_module_name") # no {key} necessary
|
222
|
-
result_folder.create()
|
223
|
-
self.assertTrue(org.uuid)
|
224
|
-
self.assertTrue(proj.uuid)
|
225
|
-
self.assertTrue(samp.uuid)
|
226
|
-
self.assertTrue(result_folder.uuid)
|
227
|
-
|
228
|
-
def test_create_sample_result_file(self):
|
229
|
-
"""Test that we can create a result file in a sample."""
|
230
|
-
key = random_str()
|
231
|
-
org = Organization(self.knex, self.org_name)
|
232
|
-
proj = org.project(f"my_client_test_proj {key}")
|
233
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
234
|
-
result_folder = samp.result_folder(f"my_client_test_module_name") # no {key} necessary
|
235
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
236
|
-
result_file = result_folder.result_file("my_client_test_field_name", {"foo": "bar"})
|
237
|
-
result_file.create()
|
238
|
-
self.assertTrue(org.uuid)
|
239
|
-
self.assertTrue(proj.uuid)
|
240
|
-
self.assertTrue(samp.uuid)
|
241
|
-
self.assertTrue(result_folder.uuid)
|
242
|
-
self.assertTrue(result_file.uuid)
|
243
|
-
|
244
|
-
@skip("failing on server (2023-10-24)")
|
245
|
-
def test_modify_sample_result_file(self):
|
246
|
-
"""Test that we can modify a result file in a sample."""
|
247
|
-
key = random_str()
|
248
|
-
org = Organization(self.knex, self.org_name)
|
249
|
-
proj = org.project(f"my_client_test_proj {key}")
|
250
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
251
|
-
result_folder = samp.result_folder(f"my_client_test_module_name") # no {key} necessary
|
252
|
-
# N.B. It should NOT be necessary to call <parent>.create()
|
253
|
-
result_file = result_folder.result_file(f"my_client_test_file_name {key}", {"foo": "bar"})
|
254
|
-
result_file.create()
|
255
|
-
self.assertTrue(result_file.uuid)
|
256
|
-
result_file.stored_data = {"foo": "bizz"} # TODO: handle deep modifications
|
257
|
-
result_file.save()
|
258
|
-
retrieved = result_folder.result_file(f"my_client_test_file_name {key}").get()
|
259
|
-
self.assertEqual(retrieved.stored_data["foo"], "bizz")
|
260
|
-
|
261
|
-
def test_get_project_manifest(self):
|
262
|
-
"""Test that we can get a project manifest."""
|
263
|
-
key = random_str()
|
264
|
-
org = Organization(self.knex, self.org_name)
|
265
|
-
proj = org.project(f"my_client_test_proj {key}")
|
266
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
267
|
-
result_folder = samp.result_folder(f"my_client_test_module_name") # no {key} necessary
|
268
|
-
result_file = result_folder.result_file("my_client_test_field_name", {"foo": "bar"})
|
269
|
-
result_file.create()
|
270
|
-
manifest = proj.get_manifest()
|
271
|
-
self.assertTrue(manifest)
|
272
|
-
|
273
|
-
def test_get_sample_manifest(self):
|
274
|
-
"""Test that we can get a sample manifest."""
|
275
|
-
key = random_str()
|
276
|
-
org = Organization(self.knex, self.org_name)
|
277
|
-
proj = org.project(f"my_client_test_proj {key}")
|
278
|
-
samp = proj.sample(f"my_client_test_sample {key}")
|
279
|
-
result_folder = samp.result_folder(f"my_client_test_module_name") # no {key} necessary
|
280
|
-
result_file = result_folder.result_file("my_client_test_field_name", {"foo": "bar"})
|
281
|
-
result_file.create()
|
282
|
-
manifest = samp.get_manifest()
|
283
|
-
self.assertTrue(manifest)
|
tests/test_plotting.py
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
"""Test suite for plotting library."""
|
2
|
-
import random
|
3
|
-
from os import environ
|
4
|
-
from os.path import dirname, join
|
5
|
-
from unittest import TestCase, skip
|
6
|
-
|
7
|
-
from geoseeq.plotting.map import Map
|
8
|
-
|
9
|
-
|
10
|
-
class TestGeoseeqPlotting(TestCase):
|
11
|
-
"""Test suite for packet building."""
|
12
|
-
|
13
|
-
def test_make_map_complex(self):
|
14
|
-
"""Test that we can create a map and turn it into a dict."""
|
15
|
-
map = Map()\
|
16
|
-
.set_center(0, 0)\
|
17
|
-
.set_zoom(2)\
|
18
|
-
.add_light_base_map()\
|
19
|
-
.add_administrative_overlay()\
|
20
|
-
.add_places_overlay()
|
21
|
-
map.to_dict()
|
22
|
-
|
23
|
-
def test_make_map_simple(self):
|
24
|
-
"""Test that we can create a map and turn it into a dict."""
|
25
|
-
map = Map()\
|
26
|
-
.add_light_base_map()
|
27
|
-
map.to_dict()
|
28
|
-
|
29
|
-
|
File without changes
|
File without changes
|
File without changes
|