labkey 3.2.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.2.0 → labkey-3.3.0}/CHANGE.txt +7 -0
- {labkey-3.2.0/labkey.egg-info → labkey-3.3.0}/PKG-INFO +1 -1
- {labkey-3.2.0 → labkey-3.3.0}/labkey/__init__.py +1 -1
- {labkey-3.2.0 → labkey-3.3.0}/labkey/domain.py +2 -2
- {labkey-3.2.0 → labkey-3.3.0}/labkey/query.py +73 -1
- {labkey-3.2.0 → labkey-3.3.0}/labkey/server_context.py +2 -1
- {labkey-3.2.0 → labkey-3.3.0/labkey.egg-info}/PKG-INFO +1 -1
- {labkey-3.2.0 → labkey-3.3.0}/LICENSE.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/MANIFEST.in +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/README.md +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/debug.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/api_wrapper.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/container.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/exceptions.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/experiment.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/security.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/storage.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey/utils.py +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey.egg-info/SOURCES.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey.egg-info/dependency_links.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey.egg-info/requires.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/labkey.egg-info/top_level.txt +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/pyproject.toml +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/pytest.ini +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/setup.cfg +0 -0
- {labkey-3.2.0 → labkey-3.3.0}/setup.py +0 -0
@@ -2,6 +2,13 @@
|
|
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
|
+
|
5
12
|
What's New in the LabKey 3.2.0 package
|
6
13
|
==============================
|
7
14
|
|
@@ -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
|
@@ -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:
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|