isabl-cli 0.1.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.
tests/test_data.py ADDED
@@ -0,0 +1,450 @@
1
+ import os
2
+ import shutil
3
+ import uuid
4
+
5
+ from click.testing import CliRunner
6
+ import click
7
+ import pytest
8
+ import yaml
9
+
10
+ from isabl_cli import api
11
+ from isabl_cli import commands
12
+ from isabl_cli import data
13
+ from isabl_cli import factories
14
+
15
+
16
+ def test_trash_analysis_storage():
17
+ # the rest is tested in test_engine
18
+ with pytest.raises(click.UsageError) as error:
19
+ data.trash_analysis_storage({"status": "SUCCEEDED"})
20
+ assert "You can't wipe a succeeded analysis" in str(error.value)
21
+
22
+
23
+ def test__make_storage_directory(tmpdir):
24
+ i = data._make_storage_directory(tmpdir.strpath, "test", 12345, use_hash=True)
25
+ j = data._make_storage_directory(tmpdir.strpath, "test", 12345, use_hash=False)
26
+ assert "/test/23/45/12345" in i
27
+ assert "/test/12345" in j
28
+
29
+
30
+ def test_local_reference_genome_importer(tmpdir):
31
+ runner = CliRunner()
32
+ command = data.LocalReferenceGenomeImporter.as_cli_command()
33
+ reference_test = tmpdir.join("test.fasta")
34
+ reference_test.write("foo")
35
+ identifier = str(uuid.uuid4())
36
+ api.create_instance("assemblies", **factories.AssemblyFactory(name=identifier))
37
+ args = [
38
+ "--genome-path",
39
+ reference_test.strpath,
40
+ "--dont-index",
41
+ "--assembly",
42
+ identifier,
43
+ ]
44
+ result = runner.invoke(command, args, catch_exceptions=False)
45
+ print(result.output)
46
+
47
+
48
+ def test_import_reference_data(tmpdir):
49
+ for model, identifier, factory in [
50
+ ("assemblies", str(uuid.uuid4()), factories.AssemblyFactory),
51
+ ("techniques", str(uuid.uuid4()), factories.TechniqueFactory),
52
+ ]:
53
+ reference_test = tmpdir.join("test.fasta")
54
+ reference_test.write("foo")
55
+ api.create_instance(model, **factory(name=identifier))
56
+ instance = data.LocalReferenceDataImporter.import_data(
57
+ identifier=identifier,
58
+ data_src=reference_test.strpath,
59
+ description="test description",
60
+ data_id="reference_link",
61
+ symlink=True,
62
+ model=model,
63
+ )
64
+
65
+ assert os.path.islink(instance["reference_data"]["reference_link"]["url"])
66
+ assert (
67
+ instance["reference_data"]["reference_link"]["description"]
68
+ == "test description"
69
+ )
70
+
71
+ instance = data.LocalReferenceDataImporter.import_data(
72
+ identifier=identifier,
73
+ data_src=reference_test.strpath,
74
+ description="test description",
75
+ data_id="reference_move",
76
+ model=model,
77
+ symlink=False,
78
+ )
79
+
80
+ assert os.path.isfile(instance["reference_data"]["reference_move"]["url"])
81
+ assert not os.path.islink(instance["reference_data"]["reference_move"]["url"])
82
+
83
+ reference_test.write("foo")
84
+ command = data.LocalReferenceDataImporter.as_cli_command()
85
+ runner = CliRunner()
86
+ args = [
87
+ "--identifier",
88
+ identifier,
89
+ "--data-src",
90
+ reference_test.strpath,
91
+ "--data-id",
92
+ "reference_move",
93
+ "--description",
94
+ "Test",
95
+ "--model",
96
+ model,
97
+ ]
98
+
99
+ result = runner.invoke(command, args, catch_exceptions=False)
100
+ assert "has already reference data registered" in result.output
101
+
102
+ args = [str(instance.pk), "--data-id", "reference_link", "--model", model]
103
+ result = runner.invoke(commands.get_reference, args, catch_exceptions=False)
104
+ assert instance["reference_data"]["reference_link"]["url"] in result.output
105
+
106
+ args = [str(instance.pk), "--resources", "--model", model]
107
+ result = runner.invoke(commands.get_reference, args, catch_exceptions=False)
108
+ assert "test description" in result.output
109
+
110
+
111
+ @pytest.mark.skipif(
112
+ not shutil.which("bgzip"), reason="bgzip required for this test, install samtools?"
113
+ )
114
+ def test_import_bedfiles(tmpdir):
115
+ technique = api.create_instance("techniques", **factories.TechniqueFactory())
116
+ targets = tmpdir.join("targets.bed")
117
+ baits = tmpdir.join("baits.bed")
118
+ targets.write("2\t1\t2\n1\t1\t2\n")
119
+ baits.write("2\t1\t2\n1\t1\t2\n")
120
+ species = "HUMAN"
121
+ runner = CliRunner()
122
+ technique = data.LocalBedImporter.import_bedfiles(
123
+ species=species,
124
+ technique=technique["pk"],
125
+ targets_path=targets.strpath,
126
+ baits_path=baits.strpath,
127
+ assembly="AnAssembly",
128
+ description="these are test BED files",
129
+ )
130
+
131
+ for i in "targets", "baits":
132
+ bedfile = technique["reference_data"][f"AnAssembly_{i}_bedfile"]["url"]
133
+ assert os.path.isfile(bedfile)
134
+ assert os.path.isfile(bedfile + ".tbi")
135
+ assert os.path.isfile(bedfile.replace(".gz", ""))
136
+ args = [str(technique.pk), "--bed-type", i]
137
+ result = runner.invoke(commands.get_bed, args, catch_exceptions=False)
138
+ assert bedfile in result.output
139
+ with open(bedfile.replace(".gz", ""), "r") as f: # test bed is sorted
140
+ assert next(f).startswith("1")
141
+
142
+ command = data.LocalBedImporter.as_cli_command()
143
+ args = [
144
+ "--targets-path",
145
+ targets.strpath,
146
+ "--baits-path",
147
+ baits.strpath,
148
+ "--technique",
149
+ technique["pk"],
150
+ "--assembly",
151
+ "AnAssembly",
152
+ "--species",
153
+ species,
154
+ "--description",
155
+ "Test",
156
+ ]
157
+ result = runner.invoke(command, args, catch_exceptions=False)
158
+ assert "has registered BED files for" in result.output
159
+
160
+
161
+ def test_local_data_import(tmpdir):
162
+ dirs = [tmpdir.strpath]
163
+ projects = [api.create_instance("projects", **factories.ProjectFactory())]
164
+ experiments = [factories.ExperimentFactory(projects=projects) for i in range(7)]
165
+ experiments = [api.create_instance("experiments", **i) for i in experiments]
166
+ keys = ",".join([str(i["pk"]) for i in experiments])
167
+
168
+ importer = data.LocalDataImporter()
169
+ _, summary = importer.import_data(directories=dirs, pk__in=keys)
170
+ obtained = len(summary.rsplit("no files matched"))
171
+ assert obtained == 7 + 1
172
+
173
+ # test can't determine type of fastq
174
+ with pytest.raises(click.UsageError) as error:
175
+ path_1 = tmpdir.join(f'{experiments[0]["system_id"]}.fastq')
176
+ path_1.write("foo")
177
+ importer.import_data(directories=dirs, pk__in=keys)
178
+
179
+ path_1.remove()
180
+ assert "cant determine fastq type from" in str(error.value)
181
+
182
+ # test imports fastq
183
+ path_1 = tmpdir.join(f'{experiments[0]["system_id"]}_R1_foo.fastq')
184
+ path_2 = tmpdir.join(f'{experiments[0]["system_id"]}_R2_foo.fastq')
185
+ path_1.write("foo")
186
+ path_2.write("foo")
187
+ _, summary = importer.import_data(directories=dirs, pk__in=keys, commit=True)
188
+ assert "samples matched: 1" in summary
189
+ assert api.Experiment(experiments[0].pk).get_fastq()
190
+
191
+ # test can exclude formats
192
+ path_1 = tmpdir.join(f'{experiments[1]["system_id"]}_1.fastq')
193
+ path_2 = tmpdir.join(f'{experiments[1]["system_id"]}.bam')
194
+ path_1.write("foo")
195
+ path_2.write("foo")
196
+ _, summary = importer.import_data(directories=dirs, pk__in=keys, dtypes=["BAM"])
197
+ assert "FASTQ_R1" not in str(summary)
198
+ assert "BAM" in str(summary)
199
+
200
+ # test can import multiple formats
201
+ _, summary = importer.import_data(directories=dirs, pk__in=keys, commit=True)
202
+ assert "FASTQ_R1" in str(summary)
203
+ assert "BAM" in str(summary)
204
+
205
+ # test raise error if duplicated ids
206
+ with pytest.raises(click.UsageError) as error:
207
+ api.patch_instance("experiments", experiments[2]["pk"], identifier="dup_id")
208
+ api.patch_instance("experiments", experiments[3]["pk"], identifier="dup_id")
209
+ importer.import_data(
210
+ key=lambda x: x["identifier"], directories=dirs, pk__in=keys
211
+ )
212
+
213
+ assert "same identifier for" in str(error.value)
214
+
215
+ # test summary
216
+ path_1 = tmpdir.join(f'_{experiments[2]["system_id"]}_cram1_.cram')
217
+ path_2 = tmpdir.join(f'_{experiments[2]["system_id"]}_cram2_.cram')
218
+ path_3 = tmpdir.join(f'_{experiments[3]["system_id"]}_bam1_.bam')
219
+ path_4 = tmpdir.join(f'_{experiments[3]["system_id"]}_bam2_.bam')
220
+ path_1.write("foo")
221
+ path_2.write("foo")
222
+ path_3.write("foo")
223
+ path_4.write("foo")
224
+ imported, summary = importer.import_data(
225
+ directories=dirs, commit=True, symlink=True, pk__in=keys
226
+ )
227
+
228
+ project = api.get_instance("projects", projects[0]["pk"])
229
+ assert project["storage_url"]
230
+ assert imported[0]["storage_usage"] > 0
231
+ assert imported[0]["raw_data"]
232
+ assert imported[1]["raw_data"]
233
+ assert "experiments" in imported[1]["storage_url"]
234
+ assert len(os.listdir(os.path.join(imported[1]["storage_url"], "data"))) == 2
235
+ assert "samples matched: 2" in summary
236
+ assert "samples skipped: 2" in summary
237
+
238
+ # test import data from command line and files_data functionality
239
+ path_1 = tmpdir.join(f'{experiments[1]["system_id"]}_1.fastq')
240
+ path_2 = tmpdir.join(f'{experiments[1]["system_id"]}_2.fastq')
241
+ path_1.write("foo")
242
+ path_2.write("foo")
243
+ api.patch_instance("experiments", experiments[1]["pk"], raw_data=None)
244
+ file_data = tmpdir.join("file_data.yaml")
245
+
246
+ with open(file_data.strpath, "w") as f:
247
+ yaml.dump(
248
+ {
249
+ os.path.basename(path_1.strpath): {"PU": "TEST_PU"},
250
+ os.path.basename(path_2.strpath): {"PU": "TEST_PU"},
251
+ },
252
+ f,
253
+ default_flow_style=False,
254
+ )
255
+
256
+ command = data.LocalDataImporter.as_cli_command()
257
+ runner = CliRunner()
258
+ args = [
259
+ "-di",
260
+ tmpdir.strpath,
261
+ "-id",
262
+ "system_id",
263
+ "-fi",
264
+ "pk__in",
265
+ keys,
266
+ "--files-data",
267
+ file_data.strpath,
268
+ "--commit",
269
+ ]
270
+
271
+ result = runner.invoke(command, args, catch_exceptions=False)
272
+ assert "samples matched: 1" in result.output
273
+ experiments[1] = api.get_instance("experiments", experiments[1]["pk"])
274
+ assert experiments[1]["raw_data"][0]["file_data"]["PU"] == "TEST_PU"
275
+ assert experiments[1]["raw_data"][1]["file_data"]["PU"] == "TEST_PU"
276
+
277
+ # test import using invalid identifier
278
+ args = ["-di", tmpdir.strpath, "-id", "sample", "-fi", "pk__in", keys]
279
+ result = runner.invoke(command, args)
280
+ assert "invalid type for identifier" in result.output
281
+
282
+ # test import data using files without read permissions
283
+ path_1 = tmpdir.join(f'{experiments[4]["system_id"]}_1.fastq')
284
+ path_2 = tmpdir.join(f'{experiments[4]["system_id"]}_2.fastq')
285
+ path_1.write("foo")
286
+ path_2.write("foo")
287
+ os.chmod(path_1.strpath, 0o000)
288
+ args = ["-di", tmpdir.strpath, "-id", "system_id", "-fi", "pk__in", keys]
289
+ result = runner.invoke(command, args)
290
+ assert "The following files are not readable by current user:" in result.output
291
+ assert path_1.strpath in result.output
292
+ assert path_2.strpath not in result.output
293
+
294
+ # test proper importing from dir with symlinked dir
295
+ fs1 = tmpdir.mkdir("fs1")
296
+ dir_1 = fs1.mkdir("dir_1")
297
+ path_1 = dir_1.join(f'{experiments[5]["system_id"]}_1.fastq')
298
+ path_2 = dir_1.join(f'{experiments[5]["system_id"]}_2.fastq')
299
+ path_1.write("foo")
300
+ path_2.write("foo")
301
+
302
+ fs2 = tmpdir.mkdir("fs2")
303
+ dir_2 = fs2.join("dir_2")
304
+ os.symlink(dir_1, dir_2, target_is_directory=True)
305
+ _, summary = importer.import_data(directories=[fs2], pk__in=keys)
306
+ assert "FASTQ_R1" in str(summary)
307
+ assert "FASTQ_R2" in str(summary)
308
+
309
+ # test copying data
310
+ path_1 = tmpdir.join(f'{experiments[6]["system_id"]}_R1_foo.fastq')
311
+ path_2 = tmpdir.join(f'{experiments[6]["system_id"]}_R2_foo.fastq')
312
+ path_1.write("foo")
313
+ path_2.write("foo")
314
+ _, summary = importer.import_data(
315
+ directories=dirs, pk=experiments[6]["pk"], commit=True, copy=True
316
+ )
317
+ assert "samples matched: 1" in summary
318
+ assert api.Experiment(experiments[6].pk).get_fastq()
319
+ assert path_1.exists()
320
+ assert path_2.exists()
321
+
322
+
323
+ def test_local_data_import_with_extra(tmpdir):
324
+ assert "test-cli-client" == os.environ.get(
325
+ "ISABL_CLIENT_ID"
326
+ ), f"export ISABL_CLIENT_ID='test-cli-client' for this test to work"
327
+
328
+ dirs = [tmpdir.strpath]
329
+ project = api.create_instance("projects", **factories.ProjectFactory())
330
+ experiment = factories.ExperimentFactory(projects=[project])
331
+ experiment = api.create_instance("experiments", **experiment)
332
+
333
+ importer = data.LocalDataImporter()
334
+ _, summary = importer.import_data(directories=dirs, pk=experiment.pk, commit=True)
335
+
336
+ # test imports files with the TEST_FORMAT .tf
337
+ path = tmpdir.join(f"{experiment.system_id}.tf")
338
+ path.write("foo")
339
+ _, summary = importer.import_data(
340
+ directories=dirs, pk__in=experiment.pk, commit=True
341
+ )
342
+ print(summary)
343
+ assert "samples matched: 1" in summary
344
+
345
+
346
+ def test_get_dst():
347
+ for i, j in [
348
+ # sequencing
349
+ ("sample.bam", "BAM"),
350
+ ("sample.cram", "CRAM"),
351
+ # imaging
352
+ ("sample.png", "PNG"),
353
+ ("sample.jpg", "JPEG"),
354
+ ("sample.jpeg", "JPEG"),
355
+ ("sample.tiff", "TIFF"),
356
+ ("sample.dicom", "DICOM"),
357
+ # text
358
+ ("sample.tsv", "TSV"),
359
+ ("sample.csv", "CSV"),
360
+ ("sample.txt", "TXT"),
361
+ ("sample.tsv.gz", "TSV"),
362
+ ("sample.csv.gz", "CSV"),
363
+ ("sample.txt.gz", "TXT"),
364
+ # other
365
+ ("sample.pdf", "PDF"),
366
+ ("sample.html", "HTML"),
367
+ ]:
368
+ assert data.raw_data_inspector(i) == j
369
+ assert not data.raw_data_inspector(i + "not raw data")
370
+
371
+ for test, fq_type in [
372
+ ("sample_R{}_moretext", "R"),
373
+ ("sample_R{}_", "R"),
374
+ ("sample_R{}", "R"),
375
+ ("sample.R{}.more_text", "R"),
376
+ ("sample.R{}.", "R"),
377
+ ("sample.R{}", "R"),
378
+ ("sample_{}", "R"),
379
+ ("sample_S1_L001_I{}_001", "I"),
380
+ ]:
381
+ for index in [1, 2]:
382
+ for fastq in [".fastq", ".fq"]:
383
+ for gzipped in ["", ".gz"]:
384
+ assert (
385
+ data.raw_data_inspector(test.format(index) + fastq + gzipped)
386
+ == f"FASTQ_{fq_type}{index}"
387
+ )
388
+
389
+
390
+ def test_extra_raw_data_formats():
391
+ assert "test-cli-client" == os.environ.get(
392
+ "ISABL_CLIENT_ID"
393
+ ), f"export ISABL_CLIENT_ID='test-cli-client' for this test to work"
394
+
395
+ for i, j in [
396
+ ("sample.tf", "TEST_FORMAT"),
397
+ ("sample.tf.gz", "TEST_FORMAT"),
398
+ ("sample.tf.gz", "TEST_FORMAT"),
399
+ ]:
400
+ assert data.raw_data_inspector(i) == j
401
+ assert not data.raw_data_inspector(i + "not raw data")
402
+
403
+
404
+ def test_yaml_data_import(tmpdir):
405
+ # create test data
406
+ projects = [api.create_instance("projects", **factories.ProjectFactory())]
407
+ experiment = factories.ExperimentFactory(projects=projects)
408
+ experiment = api.create_instance("experiments", **experiment)
409
+ data_files_yaml_path = os.path.join(tmpdir, "files_data.yaml")
410
+ file1_path = os.path.join(tmpdir, "test_file_1.fastq.gz")
411
+ file2_path = os.path.join(tmpdir, "test_file_2.fastq.gz")
412
+ data_files_yaml = {
413
+ file1_path: {"key1": "value1", "key2": "value2"},
414
+ file2_path: {"key3": "value3", "key4": "value4"},
415
+ }
416
+ open(file1_path, "w").close()
417
+ open(file2_path, "w").close()
418
+ with open(data_files_yaml_path, "w") as outfile:
419
+ yaml.dump(data_files_yaml, outfile, default_flow_style=False)
420
+
421
+ # test import from command line
422
+ command = data.LocalYamlDataImporter.as_cli_command()
423
+ runner = CliRunner()
424
+ args = [
425
+ "-fi",
426
+ "system_id",
427
+ experiment.system_id,
428
+ "--files-data",
429
+ data_files_yaml_path,
430
+ "--commit",
431
+ ]
432
+ runner.invoke(command, args, catch_exceptions=False)
433
+
434
+ # reload experiment to get raw_data
435
+ experiment = api.get_instance("experiments", experiment.identifier)
436
+
437
+ # verify imported as expected
438
+ assert experiment.raw_data is not None
439
+ assert len(experiment.raw_data) == 2
440
+ assert os.path.basename(file1_path) in experiment.raw_data[0].file_url
441
+ assert experiment.raw_data[0].file_data["key1"] == "value1"
442
+ assert experiment.raw_data[0].file_data["key2"] == "value2"
443
+ assert experiment.raw_data[0].file_type == "FASTQ_R1"
444
+ assert os.path.basename(file2_path) in experiment.raw_data[1].file_url
445
+ assert experiment.raw_data[1].file_data["key3"] == "value3"
446
+ assert experiment.raw_data[1].file_data["key4"] == "value4"
447
+ assert experiment.raw_data[1].file_type == "FASTQ_R2"
448
+
449
+ # clean up
450
+ os.remove(data_files_yaml_path)
tests/test_options.py ADDED
@@ -0,0 +1,28 @@
1
+ from click.testing import CliRunner
2
+ import click
3
+
4
+ from isabl_cli import api
5
+ from isabl_cli import factories
6
+ from isabl_cli import options
7
+
8
+ from .test_app import MockApplication
9
+
10
+
11
+ def test_get_analyses_filters_option():
12
+ runner = CliRunner()
13
+ application = MockApplication().application
14
+ analysis = api.create_instance(
15
+ "analyses", **factories.AnalysisFactory(application=application)
16
+ )
17
+
18
+ @click.command()
19
+ @options.get_analyses_filters_option([MockApplication])
20
+ def command(analyses_filters):
21
+ for i in analyses_filters:
22
+ print(i.pk)
23
+
24
+ result = runner.invoke(command, ["-fi", "pk", analysis.pk])
25
+ assert str(analysis.pk) in result.output
26
+
27
+ result = runner.invoke(command, ["--help"])
28
+ assert str(MockApplication) in result.output
tests/test_signals.py ADDED
@@ -0,0 +1,59 @@
1
+ from os.path import isfile
2
+ from os.path import join
3
+ import os
4
+
5
+ from click.testing import CliRunner
6
+ import click
7
+ import pytest
8
+
9
+ from isabl_cli import AbstractApplication
10
+ from isabl_cli import api
11
+ from isabl_cli import commands
12
+ from isabl_cli import exceptions
13
+ from isabl_cli import factories
14
+ from isabl_cli import options
15
+ from isabl_cli import utils
16
+ from isabl_cli.settings import _DEFAULTS
17
+ from isabl_cli.settings import get_application_settings
18
+ from isabl_cli.settings import system_settings
19
+
20
+ _FAILED_SIGNAL_MESSAGE = "\n\nNo worries!! This error is part of signals testing...\n\n"
21
+
22
+
23
+ def besuhof_signal(instance):
24
+ if "please fail" in instance.notes:
25
+ raise Exception(_FAILED_SIGNAL_MESSAGE)
26
+ elif "fail with different msg" in instance.notes:
27
+ raise Exception("I was told to fail, but with a different msg...")
28
+
29
+
30
+ def test_failed_signal():
31
+ analysis = api.create_instance("analyses", **factories.AnalysisFactory())
32
+ get_kwargs = dict(
33
+ target_endpoint="analyses", endpoint="signals", target_id=analysis.pk
34
+ )
35
+
36
+ # check signals work and nothing is created
37
+ api._run_signals("analyses", analysis, [besuhof_signal])
38
+ assert len(api.get_instances(**get_kwargs)) == 0
39
+
40
+ # check signals failed
41
+ analysis = api.patch_instance("analyses", analysis.pk, notes="please fail")
42
+ api._run_signals("analyses", analysis, [besuhof_signal])
43
+ instances = api.get_instances(**get_kwargs)
44
+ assert len(instances) == 1
45
+ assert _FAILED_SIGNAL_MESSAGE in instances[0].data["failure_traceback"]
46
+
47
+ # assert that error traceback is updated
48
+ runner = CliRunner()
49
+ args = f"-fi target_endpoint analyses -fi target_id {analysis.pk}".split()
50
+ api.patch_instance("analyses", analysis.pk, notes="fail with different msg")
51
+ runner.invoke(commands.rerun_signals, args, catch_exceptions=False)
52
+ instances = api.get_instances(**get_kwargs)
53
+ assert len(instances) == 1
54
+ assert "but with a different msg..." in instances[0].data["failure_traceback"]
55
+
56
+ # assert that signal is deleted after no failure is detected
57
+ api.patch_instance("analyses", analysis.pk, notes="")
58
+ runner.invoke(commands.rerun_signals, args, catch_exceptions=False)
59
+ assert len(api.get_instances(**get_kwargs)) == 0
@@ -0,0 +1,24 @@
1
+ from isabl_cli import api
2
+ from isabl_cli import factories
3
+ from isabl_cli.test import utils
4
+
5
+ from .test_app import MockApplication
6
+
7
+
8
+ def test_create_utils():
9
+ # for now just get some coverage
10
+ assert utils.create_experiment("/a/bam")
11
+ assert utils.create_pair("/tumor/bam", "/tumor/bam")
12
+ assert utils.create_test_result()
13
+
14
+
15
+ def test_assert_run():
16
+ # test assert_run utility
17
+ data = api.create_instance("projects", **factories.ProjectFactory())
18
+ data = factories.ExperimentFactory(projects=[data])
19
+ data["sample"]["individual"]["species"] = "HUMAN"
20
+ assert utils.assert_run(
21
+ application=MockApplication(),
22
+ tuples=[([api.create_instance("experiments", **data)], [])],
23
+ commit=True,
24
+ )