labkey 3.1.0__tar.gz → 3.3.0__tar.gz
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.
- {labkey-3.1.0 → labkey-3.3.0}/CHANGE.txt +14 -0
- {labkey-3.1.0/labkey.egg-info → labkey-3.3.0}/PKG-INFO +12 -1
- {labkey-3.1.0 → labkey-3.3.0}/README.md +39 -16
- labkey-3.3.0/debug.txt +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/__init__.py +1 -1
- {labkey-3.1.0 → labkey-3.3.0}/labkey/domain.py +2 -2
- {labkey-3.1.0 → labkey-3.3.0}/labkey/experiment.py +94 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/query.py +73 -1
- {labkey-3.1.0 → labkey-3.3.0}/labkey/server_context.py +2 -1
- {labkey-3.1.0 → labkey-3.3.0/labkey.egg-info}/PKG-INFO +12 -1
- {labkey-3.1.0 → labkey-3.3.0}/labkey.egg-info/SOURCES.txt +1 -0
- labkey-3.3.0/labkey.egg-info/requires.txt +20 -0
- labkey-3.3.0/setup.cfg +7 -0
- {labkey-3.1.0 → labkey-3.3.0}/setup.py +3 -3
- labkey-3.1.0/labkey.egg-info/requires.txt +0 -7
- labkey-3.1.0/setup.cfg +0 -14
- {labkey-3.1.0 → labkey-3.3.0}/LICENSE.txt +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/MANIFEST.in +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/api_wrapper.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/container.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/exceptions.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/security.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/storage.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey/utils.py +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey.egg-info/dependency_links.txt +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/labkey.egg-info/top_level.txt +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/pyproject.toml +0 -0
- {labkey-3.1.0 → labkey-3.3.0}/pytest.ini +0 -0
@@ -2,6 +2,20 @@
|
|
2
2
|
LabKey Python Client API News
|
3
3
|
+++++++++++
|
4
4
|
|
5
|
+
What's New in the LabKey 3.3.0 package
|
6
|
+
==============================
|
7
|
+
|
8
|
+
*Release date: 12/3/2024*
|
9
|
+
- Add import_rows API to query module
|
10
|
+
- Accessible via API wrappers e.g. api.query.import_rows
|
11
|
+
|
12
|
+
What's New in the LabKey 3.2.0 package
|
13
|
+
==============================
|
14
|
+
|
15
|
+
*Release date: 09/10/2024*
|
16
|
+
- Add lineage API to experiment module
|
17
|
+
- Accessible via API wrappers e.g. api.experiment.lineage()
|
18
|
+
|
5
19
|
What's New in the LabKey 3.1.0 package
|
6
20
|
==============================
|
7
21
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: labkey
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.3.0
|
4
4
|
Summary: Python client API for LabKey Server
|
5
5
|
Home-page: https://github.com/LabKey/labkey-api-python
|
6
6
|
Author: LabKey
|
@@ -26,5 +26,16 @@ Requires-Dist: pytest; extra == "test"
|
|
26
26
|
Requires-Dist: requests; extra == "test"
|
27
27
|
Requires-Dist: mock; extra == "test"
|
28
28
|
Requires-Dist: pytest-cov; extra == "test"
|
29
|
+
Provides-Extra: dev
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
31
|
+
Requires-Dist: requests; extra == "dev"
|
32
|
+
Requires-Dist: mock; extra == "dev"
|
33
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
34
|
+
Requires-Dist: black; extra == "dev"
|
35
|
+
Provides-Extra: build
|
36
|
+
Requires-Dist: setuptools; extra == "build"
|
37
|
+
Requires-Dist: build; extra == "build"
|
38
|
+
Requires-Dist: twine; extra == "build"
|
39
|
+
Requires-Dist: wheel; extra == "build"
|
29
40
|
|
30
41
|
Python client API for LabKey Server. Supports query and experiment APIs.
|
@@ -93,12 +93,16 @@ from labkey.api_wrapper import APIWrapper
|
|
93
93
|
|
94
94
|
print("Create an APIWrapper")
|
95
95
|
labkey_server = 'localhost:8080'
|
96
|
-
|
96
|
+
# in this example, Tutorials is a project name and HIV study is a subfolder under it.
|
97
|
+
container_path = 'Tutorials/HIV Study'
|
97
98
|
contextPath = 'labkey'
|
98
99
|
schema = 'core'
|
99
100
|
table = 'Users'
|
100
|
-
api = APIWrapper(labkey_server, project_name, contextPath, use_ssl=False)
|
101
101
|
|
102
|
+
# Note: If developing against localhost with https disabled, set use_ssl=False below
|
103
|
+
api = APIWrapper(labkey_server, container_path, contextPath)
|
104
|
+
|
105
|
+
# Makes an API request to https://www.example.com/labkey/tutorials/hiv%20study/query-getQuery.api
|
102
106
|
result = api.query.select_rows(schema, table)
|
103
107
|
|
104
108
|
if result is not None:
|
@@ -113,28 +117,29 @@ Python 3.7+ is fully supported.
|
|
113
117
|
LabKey Server v15.1 and later.
|
114
118
|
|
115
119
|
## Contributing
|
116
|
-
This package is maintained by [LabKey](http://www.labkey.com/). If you have any questions or need support, please use
|
117
|
-
|
118
|
-
|
119
|
-
When contributing changes please use `Black` to format your code. To run Black follow these instructions:
|
120
|
-
1. Install black: `pip install black`
|
121
|
-
2. Run black: `black .`
|
122
|
-
3. Commit the newly formatted code.
|
120
|
+
This package is maintained by [LabKey](http://www.labkey.com/). If you have any questions or need support, please use the
|
121
|
+
[LabKey Server developer support forum](https://www.labkey.org/home/developer/forum/project-start.view).
|
123
122
|
|
124
|
-
###
|
125
|
-
|
123
|
+
### Setup
|
124
|
+
To install the necessary dependencies for local development you can run the following command:
|
126
125
|
|
127
126
|
```bash
|
128
|
-
|
127
|
+
pip install -e '.[dev]'
|
129
128
|
```
|
130
129
|
|
131
|
-
|
130
|
+
|
131
|
+
### Formatting your code
|
132
|
+
When contributing changes please use `Black` to format your code. To run Black you can run the following command:
|
132
133
|
|
133
134
|
```bash
|
134
|
-
|
135
|
+
black .
|
135
136
|
```
|
136
137
|
|
137
|
-
|
138
|
+
After black has run it may have formatted some files, commit the changed files before opening a PR.
|
139
|
+
|
140
|
+
### Testing
|
141
|
+
If you are looking to contribute please run the tests before issuing a PR. The tests can be run with:
|
142
|
+
|
138
143
|
```bash
|
139
144
|
$ pytest .
|
140
145
|
```
|
@@ -147,4 +152,22 @@ $ pytest . -m "integration"
|
|
147
152
|
```
|
148
153
|
|
149
154
|
### Maintainers
|
150
|
-
Package maintainer's can reference the [Python Package Maintenance](https://docs.google.com/document/d/13nVxwyctH4YZ6gDhcrOu9Iz6qGFPAxicE1VHiVYpw9A/) document (requires permission) for updating
|
155
|
+
Package maintainer's can reference the [Python Package Maintenance](https://docs.google.com/document/d/13nVxwyctH4YZ6gDhcrOu9Iz6qGFPAxicE1VHiVYpw9A/) document (requires permission) for updating
|
156
|
+
releases.
|
157
|
+
|
158
|
+
To build the package before releasing you will need to install the build dependencies. This can be done by running:
|
159
|
+
|
160
|
+
```bash
|
161
|
+
pip install -e '.[build]'
|
162
|
+
```
|
163
|
+
|
164
|
+
To build the package you can run:
|
165
|
+
|
166
|
+
```bash
|
167
|
+
python -m build
|
168
|
+
```
|
169
|
+
|
170
|
+
You should now have a `dist/` folder with two files:
|
171
|
+
|
172
|
+
1. `labkey-<version from __init__.py>.tar.gz` - This is the source distribution
|
173
|
+
2. `labkey-<version from __init__.py>-py3-none-any.whl` - This is the wheel
|
labkey-3.3.0/debug.txt
ADDED
File without changes
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
import functools
|
17
|
-
from typing import Dict, List, Union, Tuple
|
17
|
+
from typing import Dict, List, Union, Tuple, TextIO
|
18
18
|
|
19
19
|
from .server_context import ServerContext
|
20
20
|
from labkey.query import QueryFilter
|
@@ -483,7 +483,7 @@ def get_domain_details(
|
|
483
483
|
|
484
484
|
|
485
485
|
def infer_fields(
|
486
|
-
server_context: ServerContext, data_file:
|
486
|
+
server_context: ServerContext, data_file: TextIO, container_path: str = None
|
487
487
|
) -> List[PropertyDescriptor]:
|
488
488
|
"""
|
489
489
|
Infer fields for a domain from a file
|
@@ -218,6 +218,70 @@ def save_batches(
|
|
218
218
|
return None
|
219
219
|
|
220
220
|
|
221
|
+
def lineage(
|
222
|
+
server_context: ServerContext,
|
223
|
+
lsids: List[str],
|
224
|
+
children: bool = None,
|
225
|
+
container_path: str = None,
|
226
|
+
cpas_type: str = None,
|
227
|
+
depth: int = None,
|
228
|
+
exp_type: str = None,
|
229
|
+
include_inputs_and_outputs: bool = None,
|
230
|
+
include_properties: bool = None,
|
231
|
+
include_run_steps: bool = None,
|
232
|
+
parents: bool = None,
|
233
|
+
run_protocol_lsid: str = None,
|
234
|
+
):
|
235
|
+
"""
|
236
|
+
:param server_context: A LabKey server context. See utils.create_server_context.
|
237
|
+
:param lsids: Array of LSIDs for the seed ExpData, ExpMaterials, or ExpRun
|
238
|
+
:param children: Include children in the lineage response. Defaults to true.
|
239
|
+
:param container_path: labkey container path if not already set in context
|
240
|
+
:param cpas_type: Optional LSID of a SampleSet or DataClass to filter the response. Defaults to include all.
|
241
|
+
:param depth: An optional depth argument. Defaults to include all.
|
242
|
+
:param exp_type: Optional experiment type to filter response -- either "Data", "Material", or "ExperimentRun".
|
243
|
+
Defaults to include all.
|
244
|
+
:param include_inputs_and_outputs: Include inputs and outputs in the lineage response.
|
245
|
+
:param include_properties: Include properties in the lineage response.
|
246
|
+
:param include_run_steps: Include run steps in the lineage response.
|
247
|
+
:param parents: Include parents in the lineage response. Defaults to true.
|
248
|
+
:param run_protocol_lsid: Optional Exp Run Protocol Lsid to filter response. Defaults to include all.
|
249
|
+
"""
|
250
|
+
lineage_url = server_context.build_url(
|
251
|
+
"experiment", "lineage.api", container_path=container_path
|
252
|
+
)
|
253
|
+
payload = {"lsids": lsids}
|
254
|
+
|
255
|
+
if children is not None:
|
256
|
+
payload["children"] = children
|
257
|
+
|
258
|
+
if cpas_type is not None:
|
259
|
+
payload["cpasType"] = cpas_type
|
260
|
+
|
261
|
+
if depth is not None:
|
262
|
+
payload["depth"] = depth
|
263
|
+
|
264
|
+
if exp_type is not None:
|
265
|
+
payload["expType"] = exp_type
|
266
|
+
|
267
|
+
if include_inputs_and_outputs is not None:
|
268
|
+
payload["includeInputsAndOutputs"] = include_inputs_and_outputs
|
269
|
+
|
270
|
+
if include_properties is not None:
|
271
|
+
payload["includeProperties"] = include_properties
|
272
|
+
|
273
|
+
if include_run_steps is not None:
|
274
|
+
payload["includeRunSteps"] = include_run_steps
|
275
|
+
|
276
|
+
if parents is not None:
|
277
|
+
payload["parents"] = parents
|
278
|
+
|
279
|
+
if run_protocol_lsid is not None:
|
280
|
+
payload["runProtocolLsid"] = run_protocol_lsid
|
281
|
+
|
282
|
+
return server_context.make_request(lineage_url, payload=payload, method="POST")
|
283
|
+
|
284
|
+
|
221
285
|
class ExperimentWrapper:
|
222
286
|
"""
|
223
287
|
Wrapper for all of the API methods exposed in the experiment module. Used by the APIWrapper class.
|
@@ -237,3 +301,33 @@ class ExperimentWrapper:
|
|
237
301
|
@functools.wraps(save_batches)
|
238
302
|
def save_batches(self, assay_id: int, batches: List[Batch]) -> Optional[List[Batch]]:
|
239
303
|
return save_batches(self.server_context, assay_id, batches)
|
304
|
+
|
305
|
+
@functools.wraps(lineage)
|
306
|
+
def lineage(
|
307
|
+
self,
|
308
|
+
lsids: List[str],
|
309
|
+
children: bool = None,
|
310
|
+
container_path: str = None,
|
311
|
+
cpas_type: str = None,
|
312
|
+
exp_type: str = None,
|
313
|
+
depth: int = None,
|
314
|
+
include_properties: bool = None,
|
315
|
+
include_inputs_and_outputs: bool = None,
|
316
|
+
include_run_steps: bool = None,
|
317
|
+
parents: bool = None,
|
318
|
+
run_protocol_lsid: str = None,
|
319
|
+
):
|
320
|
+
return lineage(
|
321
|
+
self.server_context,
|
322
|
+
lsids,
|
323
|
+
children,
|
324
|
+
container_path,
|
325
|
+
cpas_type,
|
326
|
+
depth,
|
327
|
+
exp_type,
|
328
|
+
parents,
|
329
|
+
include_inputs_and_outputs,
|
330
|
+
include_properties,
|
331
|
+
include_run_steps,
|
332
|
+
run_protocol_lsid,
|
333
|
+
)
|
@@ -41,7 +41,7 @@ https://www.labkey.org/home/developer/forum/project-start.view
|
|
41
41
|
############################################################################
|
42
42
|
"""
|
43
43
|
import functools
|
44
|
-
from typing import List
|
44
|
+
from typing import List, TextIO
|
45
45
|
|
46
46
|
from .server_context import ServerContext
|
47
47
|
from .utils import waf_encode
|
@@ -357,6 +357,56 @@ def insert_rows(
|
|
357
357
|
)
|
358
358
|
|
359
359
|
|
360
|
+
def import_rows(
|
361
|
+
server_context: ServerContext,
|
362
|
+
schema_name: str,
|
363
|
+
query_name: str,
|
364
|
+
data_file: TextIO,
|
365
|
+
container_path: str = None,
|
366
|
+
insert_option: str = None,
|
367
|
+
audit_behavior: str = None,
|
368
|
+
import_lookup_by_alternate_key: bool = False,
|
369
|
+
):
|
370
|
+
"""
|
371
|
+
Import row(s) into a table
|
372
|
+
:param server_context: A LabKey server context. See utils.create_server_context.
|
373
|
+
:param schema_name: schema of table
|
374
|
+
:param query_name: table name to import into
|
375
|
+
:param data_file: the file containing the rows to import. The column names in the file must match the column names
|
376
|
+
from the LabKey server.
|
377
|
+
:param container_path: labkey container path if not already set in context
|
378
|
+
:param insert_option: Whether the import action should be done as an insert, creating new rows for each provided row
|
379
|
+
of the data frame, or a merge. When merging during import, any data you provide for the rows representing records
|
380
|
+
that already exist will replace the previous values. Note that when updating an existing record, you only need to
|
381
|
+
provide the columns you wish to update, existing data for other columns will be left as is. Available options are
|
382
|
+
"INSERT" and "MERGE". Defaults to "INSERT".
|
383
|
+
:param audit_behavior: Set the level of auditing details for this import action. Available options are "SUMMARY" and
|
384
|
+
"DETAILED". SUMMARY - Audit log reflects that a change was made, but does not mention the nature of the change.
|
385
|
+
DETAILED - Provides full details on what change was made, including values before and after the change. Defaults to
|
386
|
+
the setting as specified by the LabKey query.
|
387
|
+
:param import_lookup_by_alternate_key: Allows lookup target rows to be resolved by values rather than the target's
|
388
|
+
primary key. This option will only be available for lookups that are configured with unique column information
|
389
|
+
:return:
|
390
|
+
"""
|
391
|
+
url = server_context.build_url("query", "import.api", container_path=container_path)
|
392
|
+
file_payload = {"file": data_file}
|
393
|
+
payload = {
|
394
|
+
"schemaName": schema_name,
|
395
|
+
"queryName": query_name,
|
396
|
+
}
|
397
|
+
|
398
|
+
if insert_option is not None:
|
399
|
+
payload["insertOption"] = insert_option
|
400
|
+
|
401
|
+
if audit_behavior is not None:
|
402
|
+
payload["auditBehavior"] = audit_behavior
|
403
|
+
|
404
|
+
if import_lookup_by_alternate_key is not None:
|
405
|
+
payload["importLookupByAlternateKey"] = import_lookup_by_alternate_key
|
406
|
+
|
407
|
+
return server_context.make_request(url, payload, method="POST", file_payload=file_payload)
|
408
|
+
|
409
|
+
|
360
410
|
def select_rows(
|
361
411
|
server_context: ServerContext,
|
362
412
|
schema_name: str,
|
@@ -654,6 +704,28 @@ class QueryWrapper:
|
|
654
704
|
timeout,
|
655
705
|
)
|
656
706
|
|
707
|
+
@functools.wraps(import_rows)
|
708
|
+
def import_rows(
|
709
|
+
self,
|
710
|
+
schema_name: str,
|
711
|
+
query_name: str,
|
712
|
+
data_file,
|
713
|
+
container_path: str = None,
|
714
|
+
insert_option: str = None,
|
715
|
+
audit_behavior: str = None,
|
716
|
+
import_lookup_by_alternate_key: bool = False,
|
717
|
+
):
|
718
|
+
return import_rows(
|
719
|
+
self.server_context,
|
720
|
+
schema_name,
|
721
|
+
query_name,
|
722
|
+
data_file,
|
723
|
+
container_path,
|
724
|
+
insert_option,
|
725
|
+
audit_behavior,
|
726
|
+
import_lookup_by_alternate_key,
|
727
|
+
)
|
728
|
+
|
657
729
|
@functools.wraps(select_rows)
|
658
730
|
def select_rows(
|
659
731
|
self,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
from typing import Dict, TextIO
|
1
2
|
from labkey.utils import json_dumps
|
2
3
|
from . import __version__
|
3
4
|
import requests
|
@@ -176,7 +177,7 @@ class ServerContext:
|
|
176
177
|
timeout: int = 300,
|
177
178
|
method: str = "POST",
|
178
179
|
non_json_response: bool = False,
|
179
|
-
file_payload:
|
180
|
+
file_payload: Dict[str, TextIO] = None,
|
180
181
|
json: dict = None,
|
181
182
|
allow_redirects=False,
|
182
183
|
) -> any:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: labkey
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.3.0
|
4
4
|
Summary: Python client API for LabKey Server
|
5
5
|
Home-page: https://github.com/LabKey/labkey-api-python
|
6
6
|
Author: LabKey
|
@@ -26,5 +26,16 @@ Requires-Dist: pytest; extra == "test"
|
|
26
26
|
Requires-Dist: requests; extra == "test"
|
27
27
|
Requires-Dist: mock; extra == "test"
|
28
28
|
Requires-Dist: pytest-cov; extra == "test"
|
29
|
+
Provides-Extra: dev
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
31
|
+
Requires-Dist: requests; extra == "dev"
|
32
|
+
Requires-Dist: mock; extra == "dev"
|
33
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
34
|
+
Requires-Dist: black; extra == "dev"
|
35
|
+
Provides-Extra: build
|
36
|
+
Requires-Dist: setuptools; extra == "build"
|
37
|
+
Requires-Dist: build; extra == "build"
|
38
|
+
Requires-Dist: twine; extra == "build"
|
39
|
+
Requires-Dist: wheel; extra == "build"
|
29
40
|
|
30
41
|
Python client API for LabKey Server. Supports query and experiment APIs.
|
labkey-3.3.0/setup.cfg
ADDED
@@ -33,6 +33,8 @@ if not version:
|
|
33
33
|
long_desc = "Python client API for LabKey Server. Supports query and experiment APIs."
|
34
34
|
|
35
35
|
tests_require = ["pytest", "requests", "mock", "pytest-cov"]
|
36
|
+
dev_require = ["pytest", "requests", "mock", "pytest-cov", "black"]
|
37
|
+
build_require = ["setuptools", "build", "twine", "wheel"]
|
36
38
|
|
37
39
|
setup(
|
38
40
|
name="labkey",
|
@@ -48,9 +50,7 @@ setup(
|
|
48
50
|
packages=packages,
|
49
51
|
package_data={},
|
50
52
|
install_requires=["requests"],
|
51
|
-
|
52
|
-
setup_requires=["pytest-runner"],
|
53
|
-
extras_require={"test": tests_require},
|
53
|
+
extras_require={"test": tests_require, "dev": dev_require, "build": build_require},
|
54
54
|
keywords="labkey api client",
|
55
55
|
classifiers=[
|
56
56
|
"Development Status :: 4 - Beta",
|
labkey-3.1.0/setup.cfg
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|