labkey 3.1.0__py3-none-any.whl → 3.3.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.
labkey/__init__.py CHANGED
@@ -14,6 +14,6 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  __title__ = "labkey"
17
- __version__ = "3.1.0"
17
+ __version__ = "3.3.0"
18
18
  __author__ = "LabKey"
19
19
  __license__ = "Apache License 2.0"
labkey/domain.py CHANGED
@@ -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: any, container_path: str = None
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
labkey/experiment.py CHANGED
@@ -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
+ )
labkey/query.py CHANGED
@@ -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,
labkey/server_context.py CHANGED
@@ -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: any = None,
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.1.0
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
@@ -22,9 +22,20 @@ Classifier: Topic :: Scientific/Engineering
22
22
  License-File: LICENSE.txt
23
23
  Requires-Dist: requests
24
24
  Provides-Extra: test
25
- Requires-Dist: pytest ; extra == 'test'
26
- Requires-Dist: requests ; extra == 'test'
27
- Requires-Dist: mock ; extra == 'test'
28
- Requires-Dist: pytest-cov ; extra == 'test'
25
+ Requires-Dist: pytest; extra == "test"
26
+ Requires-Dist: requests; extra == "test"
27
+ Requires-Dist: mock; extra == "test"
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.
@@ -0,0 +1,16 @@
1
+ labkey/__init__.py,sha256=TUjL83UivtADyginkvpkXQQdrAgJQNmNzevhchgQ3qQ,695
2
+ labkey/api_wrapper.py,sha256=OxnV6_5jONWiwsi24TOXTKP5inXtAfABGqXAPua3eCM,1427
3
+ labkey/container.py,sha256=DXmLhGsNnN_QLXa_tMCM0Xf_Kkz7B8KjRFhJT5I4FtY,5497
4
+ labkey/domain.py,sha256=hcyHOg3KPZFyEMccOllp9OtXMWnuzIGkbHbn8dAyfOI,22497
5
+ labkey/exceptions.py,sha256=00x-4oP_2d0SfZKxsGIs8QGvXiNq2y7C5hAzuzT3Gkk,3619
6
+ labkey/experiment.py,sha256=6U4BXnYHNXCUF_mee0maK_CZDVm_lbMjC82ywx9YCTE,12062
7
+ labkey/query.py,sha256=zQH7qO2UH8aSHLa8GhEklNvEb6fj2cjdB3AI4Q4m2n8,27133
8
+ labkey/security.py,sha256=eMa2b_22FWB2rVvVpxTeWrK0VgGTszhRchsApbDR6sA,15306
9
+ labkey/server_context.py,sha256=f0xjiE9NtoSVn6oN-C0LaJfSWaK3YgOOX5ouwLL0Szo,7787
10
+ labkey/storage.py,sha256=WpgpTWQzgig_qJXMGszFcFjtf8oMd2-6TBehSkpJPUg,6144
11
+ labkey/utils.py,sha256=oL6qmHkpzLTm_9c7gSEzumv_MVh5s8fj6bOrbuslrV0,3233
12
+ labkey-3.3.0.dist-info/LICENSE.txt,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
13
+ labkey-3.3.0.dist-info/METADATA,sha256=z5Co-n5oSWKDje8-xR7yY_3MR-kJGr9O8Xc_QL2I_tw,1468
14
+ labkey-3.3.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
15
+ labkey-3.3.0.dist-info/top_level.txt,sha256=DQIk1fQNg7NxxBsEt_K7k-aopiH87jmnU98zwDp0n04,7
16
+ labkey-3.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- labkey/__init__.py,sha256=SjBskVArzIGzH9aIlUwSK246XoguCK7iCvEm0fXQAhQ,695
2
- labkey/api_wrapper.py,sha256=OxnV6_5jONWiwsi24TOXTKP5inXtAfABGqXAPua3eCM,1427
3
- labkey/container.py,sha256=DXmLhGsNnN_QLXa_tMCM0Xf_Kkz7B8KjRFhJT5I4FtY,5497
4
- labkey/domain.py,sha256=SABG7BfSqQGJr8DPjUsvhi8C7xP2MTpkq24sdtAu4J8,22486
5
- labkey/exceptions.py,sha256=00x-4oP_2d0SfZKxsGIs8QGvXiNq2y7C5hAzuzT3Gkk,3619
6
- labkey/experiment.py,sha256=Wtuz52bhuvDWk_o2AbTw7SJnwEji2iD6Q04ct0PWSxE,8804
7
- labkey/query.py,sha256=w6vYDwiwnLalrDQ8pGY-c9DvoPQuMXaFXnZLRUiezuk,24041
8
- labkey/security.py,sha256=eMa2b_22FWB2rVvVpxTeWrK0VgGTszhRchsApbDR6sA,15306
9
- labkey/server_context.py,sha256=0YcA7BRijLMs172qTrTB12MlnIcqz4X9dkkCwSxxzaA,7741
10
- labkey/storage.py,sha256=WpgpTWQzgig_qJXMGszFcFjtf8oMd2-6TBehSkpJPUg,6144
11
- labkey/utils.py,sha256=oL6qmHkpzLTm_9c7gSEzumv_MVh5s8fj6bOrbuslrV0,3233
12
- labkey-3.1.0.dist-info/LICENSE.txt,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
13
- labkey-3.1.0.dist-info/METADATA,sha256=8O6aEerFp6Qn5B18KBaa7GGKApoNCwDDWDpaB9atXwM,1076
14
- labkey-3.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
15
- labkey-3.1.0.dist-info/top_level.txt,sha256=DQIk1fQNg7NxxBsEt_K7k-aopiH87jmnU98zwDp0n04,7
16
- labkey-3.1.0.dist-info/RECORD,,