corvic-engine 0.3.0rc76__cp38-abi3-win_amd64.whl → 0.3.0rc78__cp38-abi3-win_amd64.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.
@@ -6,14 +6,14 @@ import sqlalchemy as sa
6
6
  import sqlalchemy.orm as sa_orm
7
7
  from google.protobuf import timestamp_pb2
8
8
 
9
- from corvic import orm
9
+ from corvic import eorm, orm
10
10
  from corvic.result import InternalError, InvalidArgumentError, Ok
11
11
  from corvic_generated.model.v1alpha import models_pb2
12
12
  from corvic_generated.orm.v1 import feature_view_pb2
13
13
 
14
14
  UNCOMMITTED_ID_PREFIX = "__uncommitted_object-"
15
15
 
16
- ID = TypeVar("ID", bound=orm.BaseID[Any])
16
+ IdType = TypeVar("IdType", bound=orm.BaseID[Any])
17
17
 
18
18
 
19
19
  class _ModelProto(Protocol):
@@ -34,8 +34,8 @@ ProtoBelongsToOrgObj = TypeVar("ProtoBelongsToOrgObj", bound=_ModelBelongsToOrgP
34
34
  ProtoBelongsToRoomObj = TypeVar("ProtoBelongsToRoomObj", bound=_ModelBelongsToRoomProto)
35
35
 
36
36
 
37
- class _OrmModel(Protocol[ID]):
38
- id: sa_orm.Mapped[ID | None]
37
+ class _OrmModel(Protocol[IdType]):
38
+ id: sa_orm.Mapped[IdType | None]
39
39
 
40
40
  @sa.ext.hybrid.hybrid_property
41
41
  def created_at(self) -> datetime.datetime | None: ...
@@ -45,12 +45,12 @@ class _OrmModel(Protocol[ID]):
45
45
  def _created_at_expression(cls): ...
46
46
 
47
47
 
48
- class _OrmBelongsToOrgModel(_OrmModel[ID], Protocol):
49
- org_id: sa_orm.Mapped[orm.OrgID | None]
48
+ class _OrmBelongsToOrgModel(_OrmModel[IdType], Protocol):
49
+ org_id: sa_orm.Mapped[eorm.OrgID | None]
50
50
 
51
51
 
52
- class _OrmBelongsToRoomModel(_OrmBelongsToOrgModel[ID], Protocol):
53
- room_id: sa_orm.Mapped[orm.RoomID | None]
52
+ class _OrmBelongsToRoomModel(_OrmBelongsToOrgModel[IdType], Protocol):
53
+ room_id: sa_orm.Mapped[eorm.RoomID | None]
54
54
 
55
55
 
56
56
  OrmObj = TypeVar("OrmObj", bound=_OrmModel[Any])
@@ -58,15 +58,15 @@ OrmBelongsToOrgObj = TypeVar("OrmBelongsToOrgObj", bound=_OrmBelongsToOrgModel[A
58
58
  OrmBelongsToRoomObj = TypeVar("OrmBelongsToRoomObj", bound=_OrmBelongsToRoomModel[Any])
59
59
 
60
60
 
61
- def _orm_id_to_str(id: orm.ID | None):
61
+ def _orm_id_to_str(id: eorm.ID | None):
62
62
  if id:
63
63
  return str(id)
64
64
  return ""
65
65
 
66
66
 
67
67
  def _translate_orm_id(
68
- obj_id: str, id_class: type[ID]
69
- ) -> Ok[ID | None] | orm.InvalidORMIdentifierError:
68
+ obj_id: str, id_class: type[IdType]
69
+ ) -> Ok[IdType | None] | orm.InvalidORMIdentifierError:
70
70
  if obj_id.startswith(UNCOMMITTED_ID_PREFIX):
71
71
  return Ok(None)
72
72
  parsed_obj_id = id_class(obj_id)
@@ -88,7 +88,7 @@ def timestamp_orm_to_proto(
88
88
  return timestamp_proto
89
89
 
90
90
 
91
- def resource_orm_to_proto(resource_orm: orm.Resource) -> models_pb2.Resource:
91
+ def resource_orm_to_proto(resource_orm: eorm.Resource) -> models_pb2.Resource:
92
92
  pipeline_input_name = ""
93
93
  pipeline_id = ""
94
94
  if resource_orm.pipeline_ref:
@@ -113,7 +113,7 @@ def resource_orm_to_proto(resource_orm: orm.Resource) -> models_pb2.Resource:
113
113
  )
114
114
 
115
115
 
116
- def source_orm_to_proto(source_orm: orm.Source) -> models_pb2.Source:
116
+ def source_orm_to_proto(source_orm: eorm.Source) -> models_pb2.Source:
117
117
  return models_pb2.Source(
118
118
  id=_orm_id_to_str(source_orm.id),
119
119
  name=source_orm.name,
@@ -128,7 +128,7 @@ def source_orm_to_proto(source_orm: orm.Source) -> models_pb2.Source:
128
128
 
129
129
 
130
130
  def feature_view_source_orm_to_proto(
131
- feature_view_source_orm: orm.FeatureViewSource,
131
+ feature_view_source_orm: eorm.FeatureViewSource,
132
132
  ) -> models_pb2.FeatureViewSource:
133
133
  if feature_view_source_orm.table_op_graph.WhichOneof("op") is not None:
134
134
  op = feature_view_source_orm.table_op_graph
@@ -148,7 +148,7 @@ def feature_view_source_orm_to_proto(
148
148
 
149
149
 
150
150
  def feature_view_orm_to_proto(
151
- feature_view_orm: orm.FeatureView,
151
+ feature_view_orm: eorm.FeatureView,
152
152
  ) -> models_pb2.FeatureView:
153
153
  return models_pb2.FeatureView(
154
154
  id=_orm_id_to_str(feature_view_orm.id),
@@ -166,7 +166,7 @@ def feature_view_orm_to_proto(
166
166
 
167
167
 
168
168
  def pipeline_orm_to_proto(
169
- pipeline_orm: orm.Pipeline,
169
+ pipeline_orm: eorm.Pipeline,
170
170
  ) -> models_pb2.Pipeline:
171
171
  return models_pb2.Pipeline(
172
172
  id=_orm_id_to_str(pipeline_orm.id),
@@ -183,7 +183,7 @@ def pipeline_orm_to_proto(
183
183
  )
184
184
 
185
185
 
186
- def space_orm_to_proto(space_orm: orm.Space) -> models_pb2.Space:
186
+ def space_orm_to_proto(space_orm: eorm.Space) -> models_pb2.Space:
187
187
  return models_pb2.Space(
188
188
  id=_orm_id_to_str(space_orm.id),
189
189
  name=space_orm.name,
@@ -197,7 +197,7 @@ def space_orm_to_proto(space_orm: orm.Space) -> models_pb2.Space:
197
197
  )
198
198
 
199
199
 
200
- def room_orm_to_proto(room_orm: orm.Room) -> models_pb2.Room:
200
+ def room_orm_to_proto(room_orm: eorm.Room) -> models_pb2.Room:
201
201
  return models_pb2.Room(
202
202
  id=_orm_id_to_str(room_orm.id),
203
203
  name=room_orm.name,
@@ -207,7 +207,7 @@ def room_orm_to_proto(room_orm: orm.Room) -> models_pb2.Room:
207
207
 
208
208
 
209
209
  def completion_model_orm_to_proto(
210
- completion_model_orm: orm.CompletionModel,
210
+ completion_model_orm: eorm.CompletionModel,
211
211
  ) -> models_pb2.CompletionModel:
212
212
  return models_pb2.CompletionModel(
213
213
  id=_orm_id_to_str(completion_model_orm.id),
@@ -229,7 +229,7 @@ def completion_model_orm_to_proto(
229
229
  def add_orm_org_mixin_to_session(
230
230
  orm_obj: OrmBelongsToOrgObj,
231
231
  proto_obj: _ModelBelongsToOrgProto,
232
- id_class: type[ID],
232
+ id_class: type[IdType],
233
233
  session: sa_orm.Session,
234
234
  ) -> Ok[OrmBelongsToOrgObj] | orm.InvalidORMIdentifierError:
235
235
  match _translate_orm_id(proto_obj.id, id_class):
@@ -238,7 +238,7 @@ def add_orm_org_mixin_to_session(
238
238
  case orm.InvalidORMIdentifierError() as err:
239
239
  return err
240
240
  if proto_obj.org_id:
241
- org_id = orm.OrgID(proto_obj.org_id)
241
+ org_id = eorm.OrgID(proto_obj.org_id)
242
242
  match org_id.to_db():
243
243
  case Ok():
244
244
  orm_obj.org_id = org_id
@@ -255,24 +255,24 @@ def add_orm_org_mixin_to_session(
255
255
  def add_orm_room_mixin_to_session(
256
256
  orm_obj: OrmBelongsToRoomObj,
257
257
  proto_obj: _ModelBelongsToRoomProto,
258
- id_class: type[ID],
258
+ id_class: type[IdType],
259
259
  session: sa_orm.Session,
260
260
  ) -> Ok[OrmBelongsToRoomObj] | orm.InvalidORMIdentifierError:
261
- room_id = orm.RoomID(proto_obj.room_id)
261
+ room_id = eorm.RoomID(proto_obj.room_id)
262
262
  match room_id.to_db():
263
263
  case Ok():
264
264
  pass
265
265
  case orm.InvalidORMIdentifierError() as err:
266
266
  return err
267
- orm_obj.room_id = orm.RoomID(proto_obj.room_id)
267
+ orm_obj.room_id = eorm.RoomID(proto_obj.room_id)
268
268
  return add_orm_org_mixin_to_session(orm_obj, proto_obj, id_class, session)
269
269
 
270
270
 
271
271
  def _resource_pipeline_to_orm(
272
- proto_obj: models_pb2.Resource, orm_obj: orm.Resource, session: sa_orm.Session
272
+ proto_obj: models_pb2.Resource, orm_obj: eorm.Resource, session: sa_orm.Session
273
273
  ) -> Ok[None] | InvalidArgumentError:
274
274
  if proto_obj.pipeline_id:
275
- match _translate_orm_id(proto_obj.pipeline_id, orm.PipelineID):
275
+ match _translate_orm_id(proto_obj.pipeline_id, eorm.PipelineID):
276
276
  case orm.InvalidORMIdentifierError() as err:
277
277
  return err
278
278
  case Ok(pipeline_id):
@@ -282,7 +282,7 @@ def _resource_pipeline_to_orm(
282
282
  session.flush()
283
283
  if not orm_obj.id:
284
284
  raise InternalError("internal assertion did not hold")
285
- pipeline_input = orm.PipelineInput(
285
+ pipeline_input = eorm.PipelineInput(
286
286
  resource_id=orm_obj.id,
287
287
  name=proto_obj.pipeline_input_name,
288
288
  pipeline_id=pipeline_id,
@@ -296,8 +296,8 @@ def _resource_pipeline_to_orm(
296
296
 
297
297
  def resource_proto_to_orm(
298
298
  proto_obj: models_pb2.Resource, session: sa_orm.Session
299
- ) -> Ok[orm.Resource] | InvalidArgumentError:
300
- orm_obj = orm.Resource(
299
+ ) -> Ok[eorm.Resource] | InvalidArgumentError:
300
+ orm_obj = eorm.Resource(
301
301
  name=proto_obj.name,
302
302
  description=proto_obj.description,
303
303
  mime_type=proto_obj.mime_type,
@@ -308,7 +308,7 @@ def resource_proto_to_orm(
308
308
  latest_event=proto_obj.recent_events[-1] if proto_obj.recent_events else None,
309
309
  is_terminal=proto_obj.is_terminal,
310
310
  )
311
- add_orm_room_mixin_to_session(orm_obj, proto_obj, orm.ResourceID, session)
311
+ add_orm_room_mixin_to_session(orm_obj, proto_obj, eorm.ResourceID, session)
312
312
 
313
313
  match _resource_pipeline_to_orm(proto_obj, orm_obj, session):
314
314
  case Ok(None):
@@ -322,9 +322,9 @@ def _ensure_id(
322
322
  proto_to_orm: Callable[
323
323
  [ProtoObj, sa_orm.Session], Ok[OrmObj] | InvalidArgumentError
324
324
  ],
325
- id_type: type[ID],
325
+ id_type: type[IdType],
326
326
  session: sa_orm.Session,
327
- ) -> Ok[ID] | orm.InvalidORMIdentifierError | InvalidArgumentError:
327
+ ) -> Ok[IdType] | orm.InvalidORMIdentifierError | InvalidArgumentError:
328
328
  match _translate_orm_id(proto_obj.id, id_type):
329
329
  case orm.InvalidORMIdentifierError() as err:
330
330
  return err
@@ -343,15 +343,15 @@ def _ensure_id(
343
343
 
344
344
  def pipeline_proto_to_orm( # noqa: C901
345
345
  proto_obj: models_pb2.Pipeline, session: sa_orm.Session
346
- ) -> Ok[orm.Pipeline] | orm.InvalidORMIdentifierError | InvalidArgumentError:
347
- orm_obj = orm.Pipeline(
346
+ ) -> Ok[eorm.Pipeline] | orm.InvalidORMIdentifierError | InvalidArgumentError:
347
+ orm_obj = eorm.Pipeline(
348
348
  name=proto_obj.name,
349
349
  transformation=proto_obj.pipeline_transformation,
350
350
  description=proto_obj.description,
351
351
  )
352
352
  if proto_obj.org_id:
353
- orm_obj.org_id = orm.OrgID(proto_obj.org_id)
354
- match add_orm_room_mixin_to_session(orm_obj, proto_obj, orm.PipelineID, session):
353
+ orm_obj.org_id = eorm.OrgID(proto_obj.org_id)
354
+ match add_orm_room_mixin_to_session(orm_obj, proto_obj, eorm.PipelineID, session):
355
355
  case Ok(orm_obj):
356
356
  pass
357
357
  case orm.InvalidORMIdentifierError() as err:
@@ -361,15 +361,15 @@ def pipeline_proto_to_orm( # noqa: C901
361
361
  if not orm_obj.id:
362
362
  raise InternalError("internal assertion did not hold")
363
363
 
364
- outputs = list[orm.PipelineOutput]()
364
+ outputs = list[eorm.PipelineOutput]()
365
365
  for name, val in proto_obj.source_outputs.items():
366
- match _ensure_id(val, source_proto_to_orm, orm.SourceID, session):
366
+ match _ensure_id(val, source_proto_to_orm, eorm.SourceID, session):
367
367
  case orm.InvalidORMIdentifierError() | InvalidArgumentError() as err:
368
368
  return err
369
369
  case Ok(source_id):
370
370
  pass
371
371
  outputs.append(
372
- orm.PipelineOutput(
372
+ eorm.PipelineOutput(
373
373
  source_id=source_id,
374
374
  name=name,
375
375
  pipeline_id=orm_obj.id,
@@ -388,19 +388,19 @@ def pipeline_proto_to_orm( # noqa: C901
388
388
 
389
389
  def source_proto_to_orm(
390
390
  proto_obj: models_pb2.Source, session: sa_orm.Session
391
- ) -> Ok[orm.Source] | orm.InvalidORMIdentifierError | InvalidArgumentError:
392
- orm_obj = orm.Source(
391
+ ) -> Ok[eorm.Source] | orm.InvalidORMIdentifierError | InvalidArgumentError:
392
+ orm_obj = eorm.Source(
393
393
  name=proto_obj.name,
394
394
  table_op_graph=proto_obj.table_op_graph,
395
395
  )
396
- return add_orm_room_mixin_to_session(orm_obj, proto_obj, orm.SourceID, session)
396
+ return add_orm_room_mixin_to_session(orm_obj, proto_obj, eorm.SourceID, session)
397
397
 
398
398
 
399
399
  def space_proto_to_orm(
400
400
  proto_obj: models_pb2.Space, session: sa_orm.Session
401
- ) -> Ok[orm.Space] | orm.InvalidORMIdentifierError | InvalidArgumentError:
401
+ ) -> Ok[eorm.Space] | orm.InvalidORMIdentifierError | InvalidArgumentError:
402
402
  match _ensure_id(
403
- proto_obj.feature_view, feature_view_proto_to_orm, orm.FeatureViewID, session
403
+ proto_obj.feature_view, feature_view_proto_to_orm, eorm.FeatureViewID, session
404
404
  ):
405
405
  case orm.InvalidORMIdentifierError() | InvalidArgumentError() as err:
406
406
  return err
@@ -410,26 +410,28 @@ def space_proto_to_orm(
410
410
  if not feature_view_id:
411
411
  raise InternalError("internal assertion did not hold")
412
412
 
413
- orm_obj = orm.Space(
413
+ orm_obj = eorm.Space(
414
414
  name=proto_obj.name,
415
415
  description=proto_obj.description,
416
416
  feature_view_id=feature_view_id,
417
417
  parameters=proto_obj.space_parameters,
418
418
  auto_sync=proto_obj.auto_sync,
419
419
  )
420
- return add_orm_room_mixin_to_session(orm_obj, proto_obj, orm.SpaceID, session)
420
+ return add_orm_room_mixin_to_session(orm_obj, proto_obj, eorm.SpaceID, session)
421
421
 
422
422
 
423
423
  def feature_view_proto_to_orm(
424
424
  proto_obj: models_pb2.FeatureView, session: sa_orm.Session
425
- ) -> Ok[orm.FeatureView] | orm.InvalidORMIdentifierError | InvalidArgumentError:
426
- orm_obj = orm.FeatureView(
425
+ ) -> Ok[eorm.FeatureView] | orm.InvalidORMIdentifierError | InvalidArgumentError:
426
+ orm_obj = eorm.FeatureView(
427
427
  name=proto_obj.name,
428
428
  description=proto_obj.description,
429
429
  )
430
430
  if proto_obj.org_id:
431
- orm_obj.org_id = orm.OrgID(proto_obj.org_id)
432
- match add_orm_room_mixin_to_session(orm_obj, proto_obj, orm.FeatureViewID, session):
431
+ orm_obj.org_id = eorm.OrgID(proto_obj.org_id)
432
+ match add_orm_room_mixin_to_session(
433
+ orm_obj, proto_obj, eorm.FeatureViewID, session
434
+ ):
433
435
  case Ok(orm_obj):
434
436
  pass
435
437
  case orm.InvalidORMIdentifierError() as err:
@@ -439,7 +441,7 @@ def feature_view_proto_to_orm(
439
441
  if not orm_obj.id or not orm_obj.room_id:
440
442
  raise InternalError("internal assertion did not hold")
441
443
 
442
- new_fv_sources = list[orm.FeatureViewSource]()
444
+ new_fv_sources = list[eorm.FeatureViewSource]()
443
445
  for fvs in proto_obj.feature_view_sources:
444
446
  match _feature_view_source_proto_to_orm(
445
447
  fvs, orm_obj.room_id, orm_obj.id, session
@@ -487,39 +489,39 @@ def feature_view_proto_to_orm(
487
489
 
488
490
  def _feature_view_source_proto_to_orm(
489
491
  proto_obj: models_pb2.FeatureViewSource,
490
- room_id: orm.RoomID,
491
- feature_view_id: orm.FeatureViewID,
492
+ room_id: eorm.RoomID,
493
+ feature_view_id: eorm.FeatureViewID,
492
494
  session: sa_orm.Session,
493
- ) -> Ok[orm.FeatureViewSource] | orm.InvalidORMIdentifierError | InvalidArgumentError:
494
- match _ensure_id(proto_obj.source, source_proto_to_orm, orm.SourceID, session):
495
+ ) -> Ok[eorm.FeatureViewSource] | orm.InvalidORMIdentifierError | InvalidArgumentError:
496
+ match _ensure_id(proto_obj.source, source_proto_to_orm, eorm.SourceID, session):
495
497
  case orm.InvalidORMIdentifierError() | InvalidArgumentError() as err:
496
498
  return err
497
499
  case Ok(source_id):
498
500
  pass
499
501
 
500
502
  proto_obj.room_id = proto_obj.room_id or str(room_id)
501
- orm_obj = orm.FeatureViewSource(
503
+ orm_obj = eorm.FeatureViewSource(
502
504
  table_op_graph=proto_obj.table_op_graph,
503
505
  drop_disconnected=proto_obj.drop_disconnected,
504
506
  source_id=source_id,
505
507
  feature_view_id=feature_view_id,
506
508
  )
507
509
  return add_orm_room_mixin_to_session(
508
- orm_obj, proto_obj, orm.FeatureViewSourceID, session
510
+ orm_obj, proto_obj, eorm.FeatureViewSourceID, session
509
511
  )
510
512
 
511
513
 
512
514
  def room_proto_to_orm(
513
515
  proto_obj: models_pb2.Room, session: sa_orm.Session
514
- ) -> Ok[orm.Room] | orm.InvalidORMIdentifierError | InvalidArgumentError:
515
- orm_obj = orm.Room(name=proto_obj.name)
516
- return add_orm_org_mixin_to_session(orm_obj, proto_obj, orm.RoomID, session)
516
+ ) -> Ok[eorm.Room] | orm.InvalidORMIdentifierError | InvalidArgumentError:
517
+ orm_obj = eorm.Room(name=proto_obj.name)
518
+ return add_orm_org_mixin_to_session(orm_obj, proto_obj, eorm.RoomID, session)
517
519
 
518
520
 
519
521
  def completion_model_proto_to_orm(
520
522
  proto_obj: models_pb2.CompletionModel, session: sa_orm.Session
521
- ) -> Ok[orm.CompletionModel] | InvalidArgumentError:
522
- orm_obj = orm.CompletionModel(
523
+ ) -> Ok[eorm.CompletionModel] | InvalidArgumentError:
524
+ orm_obj = eorm.CompletionModel(
523
525
  name=proto_obj.name,
524
526
  description=proto_obj.description,
525
527
  parameters=proto_obj.parameters,
@@ -528,18 +530,18 @@ def completion_model_proto_to_orm(
528
530
  last_successful_validation=proto_obj.last_successful_validation.ToDatetime(),
529
531
  )
530
532
  return add_orm_org_mixin_to_session(
531
- orm_obj, proto_obj, orm.CompletionModelID, session
533
+ orm_obj, proto_obj, eorm.CompletionModelID, session
532
534
  )
533
535
 
534
536
 
535
537
  def source_delete_orms(
536
- orm_ids: Sequence[orm.SourceID],
538
+ orm_ids: Sequence[eorm.SourceID],
537
539
  session: sa_orm.Session,
538
540
  ) -> Ok[None] | InvalidArgumentError:
539
541
  feat_view_refs = list(
540
542
  session.scalars(
541
- sa.select(orm.FeatureViewSource.id)
542
- .where(orm.FeatureViewSource.source_id.in_(orm_ids))
543
+ sa.select(eorm.FeatureViewSource.id)
544
+ .where(eorm.FeatureViewSource.source_id.in_(orm_ids))
543
545
  .limit(1)
544
546
  )
545
547
  )
@@ -548,20 +550,20 @@ def source_delete_orms(
548
550
  return InvalidArgumentError(
549
551
  "cannot delete a source that still has feature views"
550
552
  )
551
- session.execute(sa.delete(orm.Source).where(orm.Source.id.in_(orm_ids)))
553
+ session.execute(sa.delete(eorm.Source).where(eorm.Source.id.in_(orm_ids)))
552
554
  return Ok(None)
553
555
 
554
556
 
555
557
  def pipeline_delete_orms(
556
- ids: Sequence[orm.PipelineID], session: sa_orm.Session
558
+ ids: Sequence[eorm.PipelineID], session: sa_orm.Session
557
559
  ) -> Ok[None] | InvalidArgumentError:
558
560
  source_ids = [
559
561
  val[0]
560
562
  for val in session.execute(
561
- sa.select(orm.Source.id).where(
562
- orm.Source.id.in_(
563
- sa.select(orm.PipelineOutput.source_id).where(
564
- orm.PipelineOutput.pipeline_id.in_(ids)
563
+ sa.select(eorm.Source.id).where(
564
+ eorm.Source.id.in_(
565
+ sa.select(eorm.PipelineOutput.source_id).where(
566
+ eorm.PipelineOutput.pipeline_id.in_(ids)
565
567
  )
566
568
  )
567
569
  )
@@ -575,26 +577,26 @@ def pipeline_delete_orms(
575
577
  pass
576
578
 
577
579
  session.execute(
578
- sa.delete(orm.Resource).where(
579
- orm.Resource.id.in_(
580
- sa.select(orm.PipelineInput.resource_id)
581
- .join(orm.Pipeline)
582
- .where(orm.Pipeline.id.in_(ids))
580
+ sa.delete(eorm.Resource).where(
581
+ eorm.Resource.id.in_(
582
+ sa.select(eorm.PipelineInput.resource_id)
583
+ .join(eorm.Pipeline)
584
+ .where(eorm.Pipeline.id.in_(ids))
583
585
  )
584
586
  )
585
587
  )
586
- session.execute(sa.delete(orm.Pipeline).where(orm.Pipeline.id.in_(ids)))
588
+ session.execute(sa.delete(eorm.Pipeline).where(eorm.Pipeline.id.in_(ids)))
587
589
  return Ok(None)
588
590
 
589
591
 
590
592
  def resource_delete_orms(
591
- ids: Sequence[orm.ResourceID],
592
- session: orm.Session,
593
+ ids: Sequence[eorm.ResourceID],
594
+ session: eorm.Session,
593
595
  ) -> Ok[None] | InvalidArgumentError:
594
596
  pipeline_refs = list(
595
597
  session.execute(
596
- sa.select(orm.PipelineInput.pipeline_id)
597
- .where(orm.PipelineInput.resource_id.in_(ids))
598
+ sa.select(eorm.PipelineInput.pipeline_id)
599
+ .where(eorm.PipelineInput.resource_id.in_(ids))
598
600
  .limit(1)
599
601
  )
600
602
  )
@@ -603,20 +605,20 @@ def resource_delete_orms(
603
605
  return InvalidArgumentError(
604
606
  "sources exist that reference resources to be deleted"
605
607
  )
606
- session.execute(sa.delete(orm.Resource).where(orm.Resource.id.in_(ids)))
608
+ session.execute(sa.delete(eorm.Resource).where(eorm.Resource.id.in_(ids)))
607
609
  return Ok(None)
608
610
 
609
611
 
610
612
  def feature_view_source_delete_orms(
611
- ids: Sequence[orm.FeatureViewSourceID], session: orm.Session
613
+ ids: Sequence[eorm.FeatureViewSourceID], session: eorm.Session
612
614
  ) -> Ok[None] | InvalidArgumentError:
613
615
  feat_view_refs = list(
614
616
  session.execute(
615
- sa.select(orm.FeatureView.id)
617
+ sa.select(eorm.FeatureView.id)
616
618
  .where(
617
- orm.FeatureView.id.in_(
618
- sa.select(orm.FeatureViewSource.feature_view_id).where(
619
- orm.FeatureViewSource.id.in_(ids)
619
+ eorm.FeatureView.id.in_(
620
+ sa.select(eorm.FeatureViewSource.feature_view_id).where(
621
+ eorm.FeatureViewSource.id.in_(ids)
620
622
  )
621
623
  )
622
624
  )
@@ -629,54 +631,54 @@ def feature_view_source_delete_orms(
629
631
  )
630
632
 
631
633
  session.execute(
632
- sa.delete(orm.FeatureViewSource).where(orm.FeatureViewSource.id.in_(ids))
634
+ sa.delete(eorm.FeatureViewSource).where(eorm.FeatureViewSource.id.in_(ids))
633
635
  )
634
636
  return Ok(None)
635
637
 
636
638
 
637
639
  def feature_view_delete_orms(
638
- ids: Sequence[orm.FeatureViewID], session: orm.Session
640
+ ids: Sequence[eorm.FeatureViewID], session: eorm.Session
639
641
  ) -> Ok[None] | InvalidArgumentError:
640
642
  space_refs = list(
641
643
  session.execute(
642
- sa.select(orm.Space.id).where(orm.Space.feature_view_id.in_(ids))
644
+ sa.select(eorm.Space.id).where(eorm.Space.feature_view_id.in_(ids))
643
645
  )
644
646
  )
645
647
  if space_refs:
646
648
  return InvalidArgumentError(
647
649
  "spaces exist that reference feature_views to be deleted"
648
650
  )
649
- session.execute(sa.delete(orm.FeatureView).where(orm.FeatureView.id.in_(ids)))
651
+ session.execute(sa.delete(eorm.FeatureView).where(eorm.FeatureView.id.in_(ids)))
650
652
  return Ok(None)
651
653
 
652
654
 
653
655
  def space_delete_orms(
654
- ids: Sequence[orm.SpaceID], session: orm.Session
656
+ ids: Sequence[eorm.SpaceID], session: eorm.Session
655
657
  ) -> Ok[None] | InvalidArgumentError:
656
- session.execute(sa.delete(orm.Space).where(orm.Space.id.in_(ids)))
658
+ session.execute(sa.delete(eorm.Space).where(eorm.Space.id.in_(ids)))
657
659
  return Ok(None)
658
660
 
659
661
 
660
662
  def room_delete_orms(
661
- ids: Sequence[orm.RoomID], session: orm.Session
663
+ ids: Sequence[eorm.RoomID], session: eorm.Session
662
664
  ) -> Ok[None] | InvalidArgumentError:
663
665
  source_refs = list(
664
666
  session.scalars(
665
- sa.select(orm.Source).where(orm.Source.room_id.in_(ids)).limit(1)
667
+ sa.select(eorm.Source).where(eorm.Source.room_id.in_(ids)).limit(1)
666
668
  )
667
669
  )
668
670
  if source_refs:
669
671
  return InvalidArgumentError("cannot delete a room that still has sources")
670
672
 
671
- session.execute(sa.delete(orm.Room).where(orm.Room.id.in_(ids)))
673
+ session.execute(sa.delete(eorm.Room).where(eorm.Room.id.in_(ids)))
672
674
  return Ok(None)
673
675
 
674
676
 
675
677
  def completion_model_delete_orms(
676
- ids: Sequence[orm.CompletionModelID],
677
- session: orm.Session,
678
+ ids: Sequence[eorm.CompletionModelID],
679
+ session: eorm.Session,
678
680
  ) -> Ok[None] | InvalidArgumentError:
679
681
  session.execute(
680
- sa.delete(orm.CompletionModel).where(orm.CompletionModel.id.in_(ids))
682
+ sa.delete(eorm.CompletionModel).where(eorm.CompletionModel.id.in_(ids))
681
683
  )
682
684
  return Ok(None)
corvic/model/_resource.py CHANGED
@@ -13,7 +13,7 @@ import sqlalchemy as sa
13
13
  from sqlalchemy import orm as sa_orm
14
14
  from sqlalchemy.orm.interfaces import LoaderOption
15
15
 
16
- from corvic import orm, system
16
+ from corvic import eorm, system
17
17
  from corvic.model._base_model import BelongsToRoomModel
18
18
  from corvic.model._defaults import Defaults
19
19
  from corvic.model._proto_orm_convert import (
@@ -25,36 +25,36 @@ from corvic.result import InternalError, InvalidArgumentError, NotFoundError, Ok
25
25
  from corvic_generated.model.v1alpha import models_pb2
26
26
  from corvic_generated.status.v1 import event_pb2
27
27
 
28
- SourceID: TypeAlias = orm.SourceID
29
- ResourceID: TypeAlias = orm.ResourceID
30
- RoomID: TypeAlias = orm.RoomID
31
- PipelineID: TypeAlias = orm.PipelineID
28
+ SourceID: TypeAlias = eorm.SourceID
29
+ ResourceID: TypeAlias = eorm.ResourceID
30
+ RoomID: TypeAlias = eorm.RoomID
31
+ PipelineID: TypeAlias = eorm.PipelineID
32
32
 
33
33
 
34
- class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]):
34
+ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, eorm.Resource]):
35
35
  """Resources represent import data."""
36
36
 
37
37
  @classmethod
38
38
  def orm_class(cls):
39
- return orm.Resource
39
+ return eorm.Resource
40
40
 
41
41
  @classmethod
42
42
  def id_class(cls):
43
43
  return ResourceID
44
44
 
45
45
  @classmethod
46
- def orm_to_proto(cls, orm_obj: orm.Resource) -> models_pb2.Resource:
46
+ def orm_to_proto(cls, orm_obj: eorm.Resource) -> models_pb2.Resource:
47
47
  return resource_orm_to_proto(orm_obj)
48
48
 
49
49
  @classmethod
50
50
  def proto_to_orm(
51
- cls, proto_obj: models_pb2.Resource, session: orm.Session
52
- ) -> Ok[orm.Resource] | InvalidArgumentError:
51
+ cls, proto_obj: models_pb2.Resource, session: eorm.Session
52
+ ) -> Ok[eorm.Resource] | InvalidArgumentError:
53
53
  return resource_proto_to_orm(proto_obj, session)
54
54
 
55
55
  @classmethod
56
56
  def delete_by_ids(
57
- cls, ids: Sequence[ResourceID], session: orm.Session
57
+ cls, ids: Sequence[ResourceID], session: eorm.Session
58
58
  ) -> Ok[None] | InvalidArgumentError:
59
59
  return resource_delete_orms(ids, session)
60
60
 
@@ -119,8 +119,8 @@ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]
119
119
  @classmethod
120
120
  def orm_load_options(cls) -> list[LoaderOption]:
121
121
  return [
122
- sa_orm.selectinload(orm.Resource.pipeline_ref).selectinload(
123
- orm.PipelineInput.resource
122
+ sa_orm.selectinload(eorm.Resource.pipeline_ref).selectinload(
123
+ eorm.PipelineInput.resource
124
124
  ),
125
125
  ]
126
126
 
@@ -141,25 +141,25 @@ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]
141
141
  """List resources."""
142
142
  client = client or Defaults.get_default_client()
143
143
 
144
- def query_transform(query: sa.Select[tuple[orm.Resource]]):
144
+ def query_transform(query: sa.Select[tuple[eorm.Resource]]):
145
145
  if url:
146
- query = query.where(orm.Resource.url == url)
146
+ query = query.where(eorm.Resource.url == url)
147
147
  if pipeline_id:
148
148
  query = query.where(
149
- orm.Resource.id.in_(
150
- sa.select(orm.PipelineInput.resource_id).where(
151
- orm.PipelineInput.pipeline_id == pipeline_id
149
+ eorm.Resource.id.in_(
150
+ sa.select(eorm.PipelineInput.resource_id).where(
151
+ eorm.PipelineInput.pipeline_id == pipeline_id
152
152
  )
153
153
  )
154
154
  )
155
155
  match is_terminal:
156
156
  case True:
157
- query = query.where(orm.Resource.is_terminal.is_(True))
157
+ query = query.where(eorm.Resource.is_terminal.is_(True))
158
158
  case False:
159
159
  query = query.where(
160
160
  sa.or_(
161
- orm.Resource.is_terminal.is_(False),
162
- orm.Resource.is_terminal.is_(None),
161
+ eorm.Resource.is_terminal.is_(False),
162
+ eorm.Resource.is_terminal.is_(None),
163
163
  )
164
164
  )
165
165
  case None:
@@ -207,7 +207,7 @@ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]
207
207
  client: system.Client | None,
208
208
  original_path: str = "",
209
209
  description: str = "",
210
- room_id: orm.RoomID | None = None,
210
+ room_id: eorm.RoomID | None = None,
211
211
  ) -> Self:
212
212
  client = client or Defaults.get_default_client()
213
213
  room_id = room_id or Defaults.get_default_room_id(client)
@@ -236,7 +236,7 @@ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]
236
236
  cls,
237
237
  data_frame: pl.DataFrame,
238
238
  client: system.Client | None = None,
239
- room_id: orm.RoomID | None = None,
239
+ room_id: eorm.RoomID | None = None,
240
240
  ) -> Self:
241
241
  client = client or Defaults.get_default_client()
242
242
  room_id = room_id or Defaults.get_default_room_id(client)
@@ -251,7 +251,7 @@ class Resource(BelongsToRoomModel[ResourceID, models_pb2.Resource, orm.Resource]
251
251
  blob.patch()
252
252
  return cls.from_blob(blob.url, blob, client, room_id=room_id)
253
253
 
254
- def as_input_to(self, pipeline_id: orm.PipelineID) -> Self:
254
+ def as_input_to(self, pipeline_id: eorm.PipelineID) -> Self:
255
255
  new_proto = copy.deepcopy(self.proto_self)
256
256
  new_proto.pipeline_id = str(pipeline_id)
257
257
  new_proto.pipeline_input_name = f"output-{uuid.uuid4()}"