corvic-engine 0.3.0rc43__cp38-abi3-win_amd64.whl → 0.3.0rc45__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.
corvic/model/_resource.py CHANGED
@@ -95,10 +95,6 @@ class Resource(BaseModel[ResourceID, models_pb2.Resource, orm.Resource]):
95
95
  def description(self) -> str:
96
96
  return self.proto_self.description
97
97
 
98
- @property
99
- def source_ids(self) -> list[SourceID]:
100
- return [SourceID(val) for val in self.proto_self.source_ids]
101
-
102
98
  @property
103
99
  def latest_event(self) -> event_pb2.Event | None:
104
100
  return (
@@ -122,9 +118,8 @@ class Resource(BaseModel[ResourceID, models_pb2.Resource, orm.Resource]):
122
118
  @classmethod
123
119
  def orm_load_options(cls) -> list[LoaderOption]:
124
120
  return [
125
- sa_orm.selectinload(orm.Resource.source_associations),
126
- sa_orm.selectinload(orm.Resource.pipeline_input_refs).selectinload(
127
- orm.PipelineInput.pipeline
121
+ sa_orm.selectinload(orm.Resource.pipeline_ref).selectinload(
122
+ orm.PipelineInput.resource
128
123
  ),
129
124
  ]
130
125
 
corvic/model/_source.py CHANGED
@@ -148,7 +148,6 @@ class Source(BaseModel[SourceID, models_pb2.Source, orm.Source]):
148
148
 
149
149
  proto_source = models_pb2.Source(
150
150
  name=name or resource.name,
151
- resource_id=str(resource.id),
152
151
  room_id=str(room_id),
153
152
  )
154
153
 
@@ -191,11 +190,8 @@ class Source(BaseModel[SourceID, models_pb2.Source, orm.Source]):
191
190
  @classmethod
192
191
  def orm_load_options(cls) -> list[LoaderOption]:
193
192
  return [
194
- sa_orm.selectinload(orm.Source.resource_associations).selectinload(
195
- orm.SourceResourceAssociation.resource
196
- ),
197
- sa_orm.selectinload(orm.Source.pipeline_output_refs).selectinload(
198
- orm.PipelineOutput.pipeline
193
+ sa_orm.selectinload(orm.Source.pipeline_ref).selectinload(
194
+ orm.PipelineOutput.source
199
195
  ),
200
196
  ]
201
197
 
@@ -215,18 +211,24 @@ class Source(BaseModel[SourceID, models_pb2.Source, orm.Source]):
215
211
  client = client or Defaults.get_default_client()
216
212
  additional_query_transform = None
217
213
 
218
- def resource_filter(query: sa.Select[tuple[orm.Source]]):
219
- return query.filter(
220
- orm.Source.resource_associations.any(resource_id=resource.id)
221
- | orm.Source.pipeline_output_refs.any(pipeline_id=resource.pipeline_id)
222
- )
223
-
224
214
  if resource_id is not None:
225
215
  match Resource.from_id(resource_id, client):
226
216
  case NotFoundError():
227
217
  return NotFoundError("resource not found", resource_id=resource_id)
228
218
  case Ok(resource):
219
+
220
+ def resource_filter(query: sa.Select[tuple[orm.Source]]):
221
+ return query.where(
222
+ orm.Source.id.in_(
223
+ sa.select(orm.PipelineOutput.source_id)
224
+ .join(orm.Pipeline)
225
+ .join(orm.PipelineInput)
226
+ .where(orm.PipelineInput.resource_id == resource.id)
227
+ )
228
+ )
229
+
229
230
  additional_query_transform = resource_filter
231
+
230
232
  match cls.list_as_proto(
231
233
  client,
232
234
  limit=limit,
@@ -278,7 +280,3 @@ class Source(BaseModel[SourceID, models_pb2.Source, orm.Source]):
278
280
  @property
279
281
  def pipeline_id(self) -> PipelineID | None:
280
282
  return PipelineID(self.proto_self.pipeline_id) or None
281
-
282
- @property
283
- def resource_ids(self) -> Sequence[ResourceID]:
284
- return [ResourceID(self.proto_self.resource_id)]