lamindb 0.77.2__py3-none-any.whl → 1.0rc1__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.
Files changed (89) hide show
  1. lamindb/__init__.py +39 -32
  2. lamindb/_artifact.py +95 -64
  3. lamindb/_can_curate.py +19 -10
  4. lamindb/_collection.py +51 -49
  5. lamindb/_feature.py +9 -9
  6. lamindb/_finish.py +99 -86
  7. lamindb/_from_values.py +20 -17
  8. lamindb/_is_versioned.py +2 -1
  9. lamindb/_parents.py +23 -16
  10. lamindb/_query_manager.py +3 -3
  11. lamindb/_query_set.py +85 -18
  12. lamindb/_record.py +121 -46
  13. lamindb/_run.py +3 -3
  14. lamindb/_save.py +14 -8
  15. lamindb/{_feature_set.py → _schema.py} +34 -31
  16. lamindb/_storage.py +2 -1
  17. lamindb/_transform.py +51 -23
  18. lamindb/_ulabel.py +17 -8
  19. lamindb/_view.py +15 -14
  20. lamindb/base/__init__.py +24 -0
  21. lamindb/base/fields.py +281 -0
  22. lamindb/base/ids.py +103 -0
  23. lamindb/base/types.py +51 -0
  24. lamindb/base/users.py +30 -0
  25. lamindb/base/validation.py +67 -0
  26. lamindb/core/__init__.py +19 -14
  27. lamindb/core/_context.py +297 -228
  28. lamindb/core/_data.py +44 -49
  29. lamindb/core/_describe.py +41 -31
  30. lamindb/core/_django.py +59 -44
  31. lamindb/core/_feature_manager.py +192 -168
  32. lamindb/core/_label_manager.py +22 -22
  33. lamindb/core/_mapped_collection.py +17 -14
  34. lamindb/core/_settings.py +1 -12
  35. lamindb/core/_sync_git.py +56 -9
  36. lamindb/core/_track_environment.py +1 -1
  37. lamindb/core/datasets/_core.py +5 -6
  38. lamindb/core/exceptions.py +0 -7
  39. lamindb/core/fields.py +1 -1
  40. lamindb/core/loaders.py +18 -2
  41. lamindb/core/{schema.py → relations.py} +22 -19
  42. lamindb/core/storage/_anndata_accessor.py +1 -2
  43. lamindb/core/storage/_backed_access.py +2 -1
  44. lamindb/core/storage/_tiledbsoma.py +40 -13
  45. lamindb/core/storage/objects.py +1 -1
  46. lamindb/core/storage/paths.py +13 -8
  47. lamindb/core/subsettings/__init__.py +0 -2
  48. lamindb/core/types.py +2 -23
  49. lamindb/core/versioning.py +11 -7
  50. lamindb/{_curate.py → curators/__init__.py} +700 -57
  51. lamindb/curators/_spatial.py +528 -0
  52. lamindb/integrations/_vitessce.py +1 -3
  53. lamindb/migrations/0052_squashed.py +1261 -0
  54. lamindb/migrations/0053_alter_featureset_hash_alter_paramvalue_created_by_and_more.py +57 -0
  55. lamindb/migrations/0054_alter_feature_previous_runs_and_more.py +35 -0
  56. lamindb/migrations/0055_artifact_type_artifactparamvalue_and_more.py +61 -0
  57. lamindb/migrations/0056_rename_ulabel_ref_is_name_artifactulabel_label_ref_is_name_and_more.py +22 -0
  58. lamindb/migrations/0057_link_models_latest_report_and_others.py +356 -0
  59. lamindb/migrations/0058_artifact__actions_collection__actions.py +22 -0
  60. lamindb/migrations/0059_alter_artifact__accessor_alter_artifact__hash_type_and_more.py +31 -0
  61. lamindb/migrations/0060_alter_artifact__actions.py +22 -0
  62. lamindb/migrations/0061_alter_collection_meta_artifact_alter_run_environment_and_more.py +45 -0
  63. lamindb/migrations/0062_add_is_latest_field.py +32 -0
  64. lamindb/migrations/0063_populate_latest_field.py +45 -0
  65. lamindb/migrations/0064_alter_artifact_version_alter_collection_version_and_more.py +33 -0
  66. lamindb/migrations/0065_remove_collection_feature_sets_and_more.py +22 -0
  67. lamindb/migrations/0066_alter_artifact__feature_values_and_more.py +352 -0
  68. lamindb/migrations/0067_alter_featurevalue_unique_together_and_more.py +20 -0
  69. lamindb/migrations/0068_alter_artifactulabel_unique_together_and_more.py +20 -0
  70. lamindb/migrations/0069_alter_artifact__accessor_alter_artifact__hash_type_and_more.py +1294 -0
  71. lamindb/migrations/0069_squashed.py +1770 -0
  72. lamindb/migrations/0070_lamindbv1_migrate_data.py +78 -0
  73. lamindb/migrations/0071_lamindbv1_migrate_schema.py +741 -0
  74. lamindb/migrations/0072_remove_user__branch_code_remove_user_aux_and_more.py +148 -0
  75. lamindb/migrations/0073_merge_ourprojects.py +945 -0
  76. lamindb/migrations/0074_lamindbv1_part4.py +374 -0
  77. lamindb/migrations/0075_lamindbv1_part5.py +276 -0
  78. lamindb/migrations/0076_lamindbv1_part6.py +621 -0
  79. lamindb/migrations/0077_lamindbv1_part6b.py +228 -0
  80. lamindb/migrations/0078_lamindbv1_part6c.py +468 -0
  81. lamindb/migrations/0079_alter_rundata_value_json_and_more.py +36 -0
  82. lamindb/migrations/__init__.py +0 -0
  83. lamindb/models.py +4064 -0
  84. {lamindb-0.77.2.dist-info → lamindb-1.0rc1.dist-info}/METADATA +15 -20
  85. lamindb-1.0rc1.dist-info/RECORD +100 -0
  86. {lamindb-0.77.2.dist-info → lamindb-1.0rc1.dist-info}/WHEEL +1 -1
  87. lamindb/core/subsettings/_transform_settings.py +0 -21
  88. lamindb-0.77.2.dist-info/RECORD +0 -63
  89. {lamindb-0.77.2.dist-info → lamindb-1.0rc1.dist-info}/LICENSE +0 -0
@@ -0,0 +1,78 @@
1
+ # Generated by Django 5.2 on 2025-01-05 11:58
2
+
3
+ from pathlib import Path
4
+
5
+ import lamindb_setup as ln_setup
6
+ import psycopg2
7
+ from django.db import migrations
8
+
9
+
10
+ def get_artifact_path_psycopg2(artifact_id):
11
+ """Get artifact path using psycopg2."""
12
+ query = """
13
+ SELECT
14
+ s.root || '/.lamindb/' || a.uid || a.suffix AS full_path
15
+ FROM
16
+ lamindb_artifact a
17
+ JOIN lamindb_storage s ON a.storage_id = s.id
18
+ WHERE
19
+ a.id = %s
20
+ """
21
+
22
+ with psycopg2.connect(ln_setup.settings.instance.db) as conn:
23
+ with conn.cursor() as cur:
24
+ cur.execute(query, (artifact_id,))
25
+ return cur.fetchone()[0]
26
+
27
+
28
+ def transfer_source_code(apps, schema_editor):
29
+ from lamindb._finish import notebook_to_script
30
+
31
+ Transform = apps.get_model("lamindb", "Transform")
32
+ transforms = Transform.objects.filter(
33
+ _source_code_artifact__isnull=False,
34
+ ).select_related("_source_code_artifact")
35
+
36
+ for transform in transforms:
37
+ print(f"migrating source code of transform {transform}")
38
+ artifact = transform._source_code_artifact
39
+ print("artifact", artifact.uid)
40
+
41
+ path_str = get_artifact_path_psycopg2(artifact.id)
42
+ print(ln_setup.settings.storage.root_as_str)
43
+ print(path_str)
44
+ if path_str.startswith(ln_setup.settings.storage.root_as_str):
45
+ path = (
46
+ ln_setup.settings.storage.root
47
+ / f".lamindb/{artifact.uid}{artifact.suffix}"
48
+ )
49
+ else:
50
+ path = ln_setup.core.upath.UPath(path_str)
51
+ if path.exists():
52
+ if path_str.startswith("s3://"):
53
+ local_path = Path(f"temp{path.suffix}")
54
+ path.download_to(local_path)
55
+ else:
56
+ local_path = path
57
+
58
+ if artifact.suffix == ".ipynb":
59
+ transform.source_code = notebook_to_script(transform, local_path)
60
+ else:
61
+ transform.source_code = local_path.read_text()
62
+ transform.hash = artifact.hash
63
+ path.unlink()
64
+ else:
65
+ print(f"path did not exist: {path_str}")
66
+ transform._source_code_artifact = None
67
+ transform.save()
68
+ artifact.delete()
69
+
70
+
71
+ class Migration(migrations.Migration):
72
+ dependencies = [
73
+ ("lamindb", "0069_squashed"),
74
+ ]
75
+
76
+ operations = [
77
+ migrations.RunPython(transfer_source_code),
78
+ ]