lamindb_setup 0.73.1__tar.gz → 0.73.3__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.
Files changed (92) hide show
  1. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/.gitignore +1 -0
  2. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/PKG-INFO +1 -1
  3. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/changelog.md +6 -0
  4. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-sqlite-lock.ipynb +3 -0
  5. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/__init__.py +1 -1
  6. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_init_instance.py +9 -5
  7. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_migrate.py +4 -10
  8. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_register_instance.py +4 -0
  9. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings.py +10 -5
  10. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_instance.py +15 -3
  11. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_storage.py +2 -0
  12. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/cloud_sqlite_locker.py +2 -1
  13. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_connect_instance.py +7 -7
  14. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-local/conftest.py +2 -4
  15. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-local/test_update_schema_in_hub.py +16 -9
  16. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/storage/test_storage_access.py +1 -1
  17. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/.github/workflows/build.yml +0 -0
  18. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/.github/workflows/latest-changes.jinja2 +0 -0
  19. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/.github/workflows/latest-changes.yml +0 -0
  20. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/.pre-commit-config.yaml +0 -0
  21. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/LICENSE +0 -0
  22. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/README.md +0 -0
  23. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
  24. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
  25. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
  26. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/04-test-bionty.ipynb +0 -0
  27. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
  28. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
  29. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
  30. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/test-multi-session.ipynb +0 -0
  31. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-cloud/test_notebooks.py +0 -0
  32. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-cache-management.ipynb +0 -0
  33. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
  34. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
  35. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-empty-init.ipynb +0 -0
  36. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-import-schema.ipynb +0 -0
  37. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
  38. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test-invalid-schema.ipynb +0 -0
  39. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/hub-prod/test_notebooks2.py +0 -0
  40. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/index.md +0 -0
  41. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/notebooks.md +0 -0
  42. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/docs/reference.md +0 -0
  43. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_cache.py +0 -0
  44. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_check.py +0 -0
  45. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_check_setup.py +0 -0
  46. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_close.py +0 -0
  47. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_connect_instance.py +0 -0
  48. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_delete.py +0 -0
  49. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_django.py +0 -0
  50. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_exportdb.py +0 -0
  51. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_importdb.py +0 -0
  52. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_schema.py +0 -0
  53. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_schema_metadata.py +0 -0
  54. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_set_managed_storage.py +0 -0
  55. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_setup_user.py +0 -0
  56. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/_silence_loggers.py +0 -0
  57. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/__init__.py +0 -0
  58. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_aws_credentials.py +0 -0
  59. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_aws_storage.py +0 -0
  60. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_deprecated.py +0 -0
  61. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_docs.py +0 -0
  62. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_hub_client.py +0 -0
  63. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_hub_core.py +0 -0
  64. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_hub_crud.py +0 -0
  65. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_hub_utils.py +0 -0
  66. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_load.py +0 -0
  67. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_save.py +0 -0
  68. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_store.py +0 -0
  69. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_settings_user.py +0 -0
  70. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/_setup_bionty_sources.py +0 -0
  71. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/django.py +0 -0
  72. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/exceptions.py +0 -0
  73. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/hashing.py +0 -0
  74. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/types.py +0 -0
  75. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/lamindb_setup/core/upath.py +0 -0
  76. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/noxfile.py +0 -0
  77. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/pyproject.toml +0 -0
  78. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_delete_instance.py +0 -0
  79. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_init_instance.py +0 -0
  80. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_login.py +0 -0
  81. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_migrate.py +0 -0
  82. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-cloud/test_set_storage.py +0 -0
  83. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-local/test_all.py +0 -0
  84. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-prod/conftest.py +0 -0
  85. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-prod/test_auto_connect.py +0 -0
  86. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-prod/test_django.py +0 -0
  87. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
  88. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/hub-prod/test_upath.py +0 -0
  89. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/storage/test_hashing.py +0 -0
  90. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/storage/test_storage_basis.py +0 -0
  91. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/storage/test_storage_stats.py +0 -0
  92. {lamindb_setup-0.73.1 → lamindb_setup-0.73.3}/tests/storage/test_to_url.py +0 -0
@@ -108,3 +108,4 @@ lamin_sphinx
108
108
  docs/conf.py
109
109
  _docs_tmp*
110
110
  *.lndb
111
+ _is_initialized
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb_setup
3
- Version: 0.73.1
3
+ Version: 0.73.3
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <laminlabs@gmail.com>
6
6
  Description-Content-Type: text/markdown
@@ -3,6 +3,12 @@
3
3
  <!-- prettier-ignore -->
4
4
  Name | PR | Developer | Date | Version
5
5
  --- | --- | --- | --- | ---
6
+ 💚 Fix test | [784](https://github.com/laminlabs/lamindb-setup/pull/784) | [falexwolf](https://github.com/falexwolf) | 2024-06-26 | 0.73.3
7
+ ♻️ Save schema to hub upon init | [782](https://github.com/laminlabs/lamindb-setup/pull/782) | [falexwolf](https://github.com/falexwolf) | 2024-06-24 |
8
+ 💚 Fix schema serialization test | [781](https://github.com/laminlabs/lamindb-setup/pull/781) | [falexwolf](https://github.com/falexwolf) | 2024-06-24 |
9
+ Better error message | [780](https://github.com/laminlabs/lamindb-setup/pull/780) | [falexwolf](https://github.com/falexwolf) | 2024-06-20 |
10
+ 🐛 Fix permission error when screening for local storage root | [778](https://github.com/laminlabs/lamindb-setup/pull/778) | [falexwolf](https://github.com/falexwolf) | 2024-06-19 | 0.73.2
11
+ 🐛 Fix same root check in get_locker | [777](https://github.com/laminlabs/lamindb-setup/pull/777) | [Koncopd](https://github.com/Koncopd) | 2024-06-13 |
6
12
  ✨ Add .ome.zarr as composite suffix | [775](https://github.com/laminlabs/lamindb-setup/pull/775) | [sunnyosun](https://github.com/sunnyosun) | 2024-06-05 |
7
13
  🏗️ Update instance schema in the hub | [774](https://github.com/laminlabs/lamindb-setup/pull/774) | [fredericenard](https://github.com/fredericenard) | 2024-06-04 |
8
14
  ⬆️ Migrate to upath 0.2.2 | [723](https://github.com/laminlabs/lamindb-setup/pull/723) | [Koncopd](https://github.com/Koncopd) | 2024-06-02 |
@@ -75,6 +75,9 @@
75
75
  "source": [
76
76
  "ln_setup.init(storage=\"s3://lamindb-ci/test-load-lock\", name=\"test-load-lock\")\n",
77
77
  "instance_id = ln_setup.settings.instance._id\n",
78
+ "\n",
79
+ "assert ln_setup.settings.instance._cloud_sqlite_locker is ln_setup.settings.instance._cloud_sqlite_locker\n",
80
+ "\n",
78
81
  "ln_setup.close()"
79
82
  ]
80
83
  },
@@ -34,7 +34,7 @@ Modules & settings:
34
34
 
35
35
  """
36
36
 
37
- __version__ = "0.73.1" # denote a release candidate for 0.1.0 with 0.1rc1
37
+ __version__ = "0.73.3" # denote a release candidate for 0.1.0 with 0.1rc1
38
38
 
39
39
  import sys
40
40
  from os import name as _os_name
@@ -33,8 +33,7 @@ def get_schema_module_name(schema_name) -> str:
33
33
  if module_spec is not None:
34
34
  return name
35
35
  raise ImportError(
36
- f"Python package for '{schema_name}' is not installed, tried two package names:"
37
- f" {name_attempts}\nHave you installed the schema package using `pip install`?"
36
+ f"Python package for '{schema_name}' is not installed.\nIf your package is on PyPI, run `pip install {schema_name}`"
38
37
  )
39
38
 
40
39
 
@@ -256,7 +255,10 @@ def init(
256
255
  schema=schema,
257
256
  uid=ssettings.uid,
258
257
  )
259
- if isettings.is_remote and instance_state != "instance-corrupted-or-deleted":
258
+ register_on_hub = (
259
+ isettings.is_remote and instance_state != "instance-corrupted-or-deleted"
260
+ )
261
+ if register_on_hub:
260
262
  init_instance_hub(isettings)
261
263
  validate_sqlite_state(isettings)
262
264
  isettings._persist()
@@ -270,8 +272,10 @@ def init(
270
272
  "locked instance (to unlock and push changes to the cloud SQLite file,"
271
273
  " call: lamin close)"
272
274
  )
273
- # we can debate whether this is the right setting, but this is how
274
- # things have been and we'd like to not easily break backward compat
275
+ if register_on_hub and isettings.dialect != "sqlite":
276
+ from ._schema_metadata import update_schema_in_hub
277
+
278
+ update_schema_in_hub()
275
279
  settings.auto_connect = True
276
280
  except Exception as e:
277
281
  from ._delete import delete_by_isettings
@@ -75,21 +75,15 @@ class migrate:
75
75
  from lamindb_setup.core._hub_client import call_with_fallback_auth
76
76
  from lamindb_setup.core._hub_crud import (
77
77
  select_collaborator,
78
- select_instance_by_id,
79
78
  update_instance,
80
79
  )
81
80
 
82
- instance_id_str = settings.instance._id.hex
83
- instance = call_with_fallback_auth(
84
- select_instance_by_id, instance_id=instance_id_str
85
- )
86
- instance_is_on_hub = instance is not None
87
- if instance_is_on_hub:
81
+ if settings.instance.is_on_hub:
88
82
  # double check that user is an admin, otherwise will fail below
89
- # without idempotence
83
+ # due to insufficient SQL permissions with cryptic error
90
84
  collaborator = call_with_fallback_auth(
91
85
  select_collaborator,
92
- instance_id=instance_id_str,
86
+ instance_id=settings.instance._id,
93
87
  account_id=settings.user._uuid,
94
88
  )
95
89
  if collaborator is None or collaborator["role"] != "admin":
@@ -104,7 +98,7 @@ class migrate:
104
98
  # this sets up django and deploys the migrations
105
99
  setup_django(settings.instance, deploy_migrations=True)
106
100
  # this populates the hub
107
- if instance_is_on_hub:
101
+ if settings.instance.is_on_hub:
108
102
  logger.important(f"updating lamindb version in hub: {lamindb.__version__}")
109
103
  # TODO: integrate update of instance table within update_schema_in_hub & below
110
104
  if settings.instance.dialect != "sqlite":
@@ -27,3 +27,7 @@ def register(_test: bool = False):
27
27
  init_instance_hub(isettings)
28
28
  isettings._is_on_hub = True
29
29
  isettings._persist()
30
+ if isettings.dialect != "sqlite" and not _test:
31
+ from ._schema_metadata import update_schema_in_hub
32
+
33
+ update_schema_in_hub()
@@ -51,7 +51,11 @@ class SetupSettings:
51
51
  @property
52
52
  def user(self) -> UserSettings:
53
53
  """:class:`~lamindb.setup.core.UserSettings`."""
54
- if self._user_settings is None or self._user_settings_env != get_env_name():
54
+ env_changed = (
55
+ self._user_settings_env is not None
56
+ and self._user_settings_env != get_env_name()
57
+ )
58
+ if self._user_settings is None or env_changed:
55
59
  self._user_settings = load_or_create_user_settings()
56
60
  self._user_settings_env = get_env_name()
57
61
  if self._user_settings and self._user_settings.uid is None:
@@ -61,10 +65,11 @@ class SetupSettings:
61
65
  @property
62
66
  def instance(self) -> InstanceSettings:
63
67
  """:class:`~lamindb.setup.core.InstanceSettings`."""
64
- if (
65
- self._instance_settings is None
66
- or self._instance_settings_env != get_env_name()
67
- ):
68
+ env_changed = (
69
+ self._instance_settings_env is not None
70
+ and self._instance_settings_env != get_env_name()
71
+ )
72
+ if self._instance_settings is None or env_changed:
68
73
  self._instance_settings = load_instance_settings()
69
74
  self._instance_settings_env = get_env_name()
70
75
  return self._instance_settings # type: ignore
@@ -120,13 +120,25 @@ class InstanceSettings:
120
120
  if root_path.exists():
121
121
  marker_path = root_path / ".lamindb/_is_initialized"
122
122
  if marker_path.exists():
123
- uid = marker_path.read_text()
123
+ try:
124
+ uid = marker_path.read_text()
125
+ except PermissionError:
126
+ logger.warning(
127
+ f"ignoring the following location because no permission to read it: {marker_path}"
128
+ )
129
+ continue
124
130
  if uid == record.uid:
125
131
  found = True
126
132
  break
127
133
  elif uid == "":
128
- # legacy instance that was not yet marked properly
129
- mark_storage_root(record.root, record.uid)
134
+ try:
135
+ # legacy instance that was not yet marked properly
136
+ mark_storage_root(record.root, record.uid)
137
+ except PermissionError:
138
+ logger.warning(
139
+ f"ignoring the following location because no permission to write to it: {marker_path}"
140
+ )
141
+ continue
130
142
  else:
131
143
  continue
132
144
  else:
@@ -121,6 +121,8 @@ def init_storage(
121
121
  init_storage_hub(ssettings)
122
122
  # below comes last only if everything else was successful
123
123
  try:
124
+ # (federated) credentials for AWS access are provisioned under-the-hood
125
+ # discussion: https://laminlabs.slack.com/archives/C04FPE8V01W/p1719260587167489
124
126
  mark_storage_root(ssettings.root, ssettings.uid) # type: ignore
125
127
  except Exception:
126
128
  logger.important(
@@ -111,6 +111,7 @@ class Locker:
111
111
  if self._counter <= MAX_MSG_COUNTER:
112
112
  self._counter += 1
113
113
 
114
+ # Lamport's bakery algorithm
114
115
  def _lock_unsafe(self):
115
116
  if self._has_lock:
116
117
  return None
@@ -186,7 +187,7 @@ def get_locker(isettings) -> Locker:
186
187
  if (
187
188
  _locker is None
188
189
  or _locker.user != user_uid
189
- or _locker.root is not storage_root
190
+ or _locker.root != storage_root
190
191
  or _locker.instance_id != isettings._id
191
192
  ):
192
193
  _locker = Locker(user_uid, storage_root, isettings._id)
@@ -28,7 +28,7 @@ def test_connect_after_revoked_access():
28
28
  # if a previous test run failed, this will
29
29
  # error with a violation of a unique constraint
30
30
  collaborator_handler.add_by_slug(
31
- "laminlabs/static-test-instance-private-sqlite",
31
+ "testuser1/static-test-instance-private-sqlite",
32
32
  "testuser2",
33
33
  "write",
34
34
  "default",
@@ -38,19 +38,19 @@ def test_connect_after_revoked_access():
38
38
  pass
39
39
  ln_setup.login("testuser2@lamin.ai")
40
40
  ln_setup.connect(
41
- "https://lamin.ai/laminlabs/static-test-instance-private-sqlite", _test=True
41
+ "https://lamin.ai/testuser1/static-test-instance-private-sqlite", _test=True
42
42
  )
43
43
  assert (
44
44
  ln_setup.settings.instance.storage.root_as_str
45
45
  == "s3://lamindb-setup-private-bucket"
46
46
  )
47
47
  collaborator_handler.delete_by_slug(
48
- "laminlabs/static-test-instance-private-sqlite", "testuser2"
48
+ "testuser1/static-test-instance-private-sqlite", "testuser2"
49
49
  )
50
50
  # make the instance private
51
51
  with pytest.raises(InstanceNotFoundError):
52
52
  ln_setup.connect(
53
- "https://lamin.ai/laminlabs/static-test-instance-private-sqlite",
53
+ "https://lamin.ai/testuser1/static-test-instance-private-sqlite",
54
54
  _test=True,
55
55
  )
56
56
 
@@ -61,7 +61,7 @@ def test_connect_after_private_public_switch():
61
61
  # this assumes that testuser1 is an admin of static-test-instance-private-sqlite
62
62
  ln_setup.login("testuser1@lamin.ai")
63
63
  ln_setup.connect(
64
- "https://lamin.ai/laminlabs/static-test-instance-private-sqlite", _test=True
64
+ "https://lamin.ai/testuser1/static-test-instance-private-sqlite", _test=True
65
65
  )
66
66
  admin_hub = connect_hub_with_auth()
67
67
  # make the instance private
@@ -74,7 +74,7 @@ def test_connect_after_private_public_switch():
74
74
  ln_setup.login("testuser2")
75
75
  with pytest.raises(InstanceNotFoundError):
76
76
  ln_setup.connect(
77
- "https://lamin.ai/laminlabs/static-test-instance-private-sqlite",
77
+ "https://lamin.ai/testuser1/static-test-instance-private-sqlite",
78
78
  _test=True,
79
79
  )
80
80
  # make the instance public
@@ -85,7 +85,7 @@ def test_connect_after_private_public_switch():
85
85
  )
86
86
  # load instance with non-collaborator user, should work now
87
87
  ln_setup.connect(
88
- "https://lamin.ai/laminlabs/static-test-instance-private-sqlite", _test=True
88
+ "https://lamin.ai/testuser1/static-test-instance-private-sqlite", _test=True
89
89
  )
90
90
  # make the instance private again
91
91
  update_instance(
@@ -14,10 +14,8 @@ local_setup_state = setup_local_hub()
14
14
 
15
15
 
16
16
  def pytest_configure():
17
- if os.environ["LAMIN_ENV"] == "local":
18
- local_setup_state.__enter__()
19
- else:
20
- logger.warning("you're running non-local tests")
17
+ assert os.environ["LAMIN_ENV"] == "local"
18
+ local_setup_state.__enter__()
21
19
 
22
20
 
23
21
  def pytest_unconfigure():
@@ -9,17 +9,20 @@ def setup_instance():
9
9
  storage="./test_storage",
10
10
  schema="bionty,wetlab",
11
11
  db="postgresql://postgres:postgres@127.0.0.1:54322/postgres",
12
- name="testdb",
12
+ name="test-update-schema",
13
13
  )
14
14
  ln_setup.register()
15
15
  yield
16
- ln_setup.delete("testdb", force=True)
16
+ ln_setup.delete("test-update-schema", force=True)
17
17
 
18
18
 
19
19
  def test_update_schema_in_hub(setup_instance):
20
20
  is_new, schema_uuid, schema = update_schema_in_hub()
21
21
 
22
- assert is_new is True
22
+ # TODO: construct a test in which is_new is true
23
+ # currently it's false because the schema is already registered
24
+ # via `lamin register` earlier in the test
25
+ assert not is_new
23
26
  assert _dict_to_uuid(schema["json"]) == schema_uuid
24
27
 
25
28
  assert len(schema["module_set_info"]) == 3
@@ -38,6 +41,7 @@ def test_update_schema_in_hub(setup_instance):
38
41
  assert "bionty" in schema["json"]
39
42
  assert "wetlab" in schema["json"]
40
43
 
44
+ print(schema["json"]["core"]["artifact"]["fields"]["id"])
41
45
  assert schema["json"]["core"]["artifact"]["fields"]["id"] == {
42
46
  "type": "AutoField",
43
47
  "column": "id",
@@ -53,6 +57,7 @@ def test_update_schema_in_hub(setup_instance):
53
57
  "through": None,
54
58
  }
55
59
 
60
+ print(schema["json"]["core"]["artifact"]["fields"]["created_by"])
56
61
  assert schema["json"]["core"]["artifact"]["fields"]["created_by"] == {
57
62
  "type": "ForeignKey",
58
63
  "column": "created_by_id",
@@ -68,6 +73,7 @@ def test_update_schema_in_hub(setup_instance):
68
73
  "through": None,
69
74
  }
70
75
 
76
+ print(schema["json"]["bionty"]["gene"]["fields"]["pathways"])
71
77
  assert schema["json"]["bionty"]["gene"]["fields"]["pathways"] == {
72
78
  "type": "ManyToManyField",
73
79
  "column": None,
@@ -87,23 +93,24 @@ def test_update_schema_in_hub(setup_instance):
87
93
  },
88
94
  }
89
95
 
96
+ print(schema["json"]["wetlab"]["well"]["fields"]["artifacts"])
90
97
  assert schema["json"]["wetlab"]["well"]["fields"]["artifacts"] == {
91
98
  "type": "ManyToManyField",
92
99
  "column": None,
100
+ "through": {
101
+ "wetlab_well": "well_id",
102
+ "link_table_name": "wetlab_well_artifacts",
103
+ "lnschema_core_artifact": "artifact_id",
104
+ },
93
105
  "field_name": "artifacts",
94
106
  "model_name": "well",
95
107
  "schema_name": "wetlab",
96
- "select_term": 'ARRAY(SELECT JSONB_BUILD_OBJECT((\'version\')::text, U0."version", (\'created_at\')::text, U0."created_at", (\'updated_at\')::text, U0."updated_at", (\'id\')::text, U0."id", (\'uid\')::text, U0."uid", (\'description\')::text, U0."description", (\'key\')::text, U0."key", (\'suffix\')::text, U0."suffix", (\'accessor\')::text, U0."accessor", (\'size\')::text, U0."size", (\'hash\')::text, U0."hash", (\'hash_type\')::text, U0."hash_type", (\'n_objects\')::text, U0."n_objects", (\'n_observations\')::text, U0."n_observations", (\'visibility\')::text, U0."visibility", (\'key_is_virtual\')::text, U0."key_is_virtual") AS "data" FROM "lnschema_core_artifact" U0 INNER JOIN "wetlab_well_artifacts" U1 ON (U0."id" = U1."artifact_id") WHERE U1."well_id" = ("wetlab_well"."id") LIMIT 5) AS "artifacts"',
108
+ "select_term": 'ARRAY(SELECT JSONB_BUILD_OBJECT((\'version\')::text, U0."version", (\'created_at\')::text, U0."created_at", (\'updated_at\')::text, U0."updated_at", (\'id\')::text, U0."id", (\'uid\')::text, U0."uid", (\'description\')::text, U0."description", (\'key\')::text, U0."key", (\'suffix\')::text, U0."suffix", (\'type\')::text, U0."type", (\'accessor\')::text, U0."accessor", (\'size\')::text, U0."size", (\'hash\')::text, U0."hash", (\'hash_type\')::text, U0."hash_type", (\'n_objects\')::text, U0."n_objects", (\'n_observations\')::text, U0."n_observations", (\'visibility\')::text, U0."visibility", (\'key_is_virtual\')::text, U0."key_is_virtual") AS "data" FROM "lnschema_core_artifact" U0 INNER JOIN "wetlab_well_artifacts" U1 ON (U0."id" = U1."artifact_id") WHERE U1."well_id" = ("wetlab_well"."id") LIMIT 5) AS "artifacts"',
97
109
  "is_link_table": False,
98
110
  "relation_type": "many-to-many",
99
111
  "related_field_name": "wells",
100
112
  "related_model_name": "artifact",
101
113
  "related_schema_name": "core",
102
- "through": {
103
- "wetlab_well": "well_id",
104
- "link_table_name": "wetlab_well_artifacts",
105
- "lnschema_core_artifact": "artifact_id",
106
- },
107
114
  }
108
115
 
109
116
 
@@ -17,7 +17,7 @@ def test_connect_instance_with_private_storage_and_no_storage_access():
17
17
  # this should fail because of insufficient AWS permission for the storage bucket
18
18
  # that has the SQLite file on it, but because _test=True, we don't actually try to
19
19
  # pull the SQLite file -> see the line below to proxy this
20
- ln_setup.connect("laminlabs/static-test-instance-private-sqlite", _test=True)
20
+ ln_setup.connect("testuser1/static-test-instance-private-sqlite", _test=True)
21
21
  with pytest.raises(PermissionError):
22
22
  (ln_setup.settings.storage.root / "test_file").exists()
23
23
  # connecting to a postgres instance should work because it doesn't touch
File without changes
File without changes