cocoindex 0.1.64__cp311-cp311-manylinux_2_28_aarch64.whl → 0.1.65__cp311-cp311-manylinux_2_28_aarch64.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.
cocoindex/__init__.py CHANGED
@@ -11,6 +11,7 @@ from .flow import FlowBuilder, DataScope, DataSlice, Flow, transform_flow
11
11
  from .flow import flow_def
12
12
  from .flow import EvaluateAndDumpOptions, GeneratedField
13
13
  from .flow import FlowLiveUpdater, FlowLiveUpdaterOptions
14
+ from .flow import add_flow_def, remove_flow
14
15
  from .flow import update_all_flows_async, setup_all_flows, drop_all_flows
15
16
  from .lib import init, start_server, stop
16
17
  from .llm import LlmSpec, LlmApiType
@@ -52,6 +53,8 @@ __all__ = [
52
53
  "GeneratedField",
53
54
  "FlowLiveUpdater",
54
55
  "FlowLiveUpdaterOptions",
56
+ "add_flow_def",
57
+ "remove_flow",
55
58
  "update_all_flows_async",
56
59
  "setup_all_flows",
57
60
  "drop_all_flows",
cocoindex/flow.py CHANGED
@@ -624,7 +624,7 @@ class Flow:
624
624
 
625
625
  _name: str
626
626
  _full_name: str
627
- _lazy_engine_flow: Callable[[], _engine.Flow]
627
+ _lazy_engine_flow: Callable[[], _engine.Flow] | None
628
628
 
629
629
  def __init__(
630
630
  self, name: str, full_name: str, engine_flow_creator: Callable[[], _engine.Flow]
@@ -664,18 +664,18 @@ class Flow:
664
664
  return tree
665
665
 
666
666
  def _get_spec(self, verbose: bool = False) -> _engine.RenderedSpec:
667
- return self._lazy_engine_flow().get_spec(
667
+ return self.internal_flow().get_spec(
668
668
  output_mode="verbose" if verbose else "concise"
669
669
  )
670
670
 
671
671
  def _get_schema(self) -> list[tuple[str, str, str]]:
672
- return cast(list[tuple[str, str, str]], self._lazy_engine_flow().get_schema())
672
+ return cast(list[tuple[str, str, str]], self.internal_flow().get_schema())
673
673
 
674
674
  def __str__(self) -> str:
675
675
  return str(self._get_spec())
676
676
 
677
677
  def __repr__(self) -> str:
678
- return repr(self._lazy_engine_flow())
678
+ return repr(self.internal_flow())
679
679
 
680
680
  @property
681
681
  def name(self) -> str:
@@ -715,12 +715,14 @@ class Flow:
715
715
  """
716
716
  Evaluate the flow and dump flow outputs to files.
717
717
  """
718
- return self._lazy_engine_flow().evaluate_and_dump(dump_engine_object(options))
718
+ return self.internal_flow().evaluate_and_dump(dump_engine_object(options))
719
719
 
720
720
  def internal_flow(self) -> _engine.Flow:
721
721
  """
722
722
  Get the engine flow.
723
723
  """
724
+ if self._lazy_engine_flow is None:
725
+ raise RuntimeError(f"Flow {self.full_name} is already removed")
724
726
  return self._lazy_engine_flow()
725
727
 
726
728
  async def internal_flow_async(self) -> _engine.Flow:
@@ -731,13 +733,13 @@ class Flow:
731
733
 
732
734
  def setup(self, report_to_stdout: bool = False) -> None:
733
735
  """
734
- Setup the flow.
736
+ Setup persistent backends of the flow.
735
737
  """
736
738
  execution_context.run(self.setup_async(report_to_stdout=report_to_stdout))
737
739
 
738
740
  async def setup_async(self, report_to_stdout: bool = False) -> None:
739
741
  """
740
- Setup the flow. The async version.
742
+ Setup persistent backends of the flow. The async version.
741
743
  """
742
744
  await make_setup_bundle([self]).describe_and_apply_async(
743
745
  report_to_stdout=report_to_stdout
@@ -745,13 +747,18 @@ class Flow:
745
747
 
746
748
  def drop(self, report_to_stdout: bool = False) -> None:
747
749
  """
748
- Drop the flow.
750
+ Drop persistent backends of the flow.
751
+
752
+ The current instance is still valid after it's called.
753
+ For example, you can still call `setup()` after it, to setup the persistent backends again.
754
+
755
+ Call `cocoindex.remove_flow()` if you want to remove the flow from the current process.
749
756
  """
750
757
  execution_context.run(self.drop_async(report_to_stdout=report_to_stdout))
751
758
 
752
759
  async def drop_async(self, report_to_stdout: bool = False) -> None:
753
760
  """
754
- Drop the flow. The async version.
761
+ Drop persistent backends of the flow. The async version.
755
762
  """
756
763
  await make_drop_bundle([self]).describe_and_apply_async(
757
764
  report_to_stdout=report_to_stdout
@@ -805,6 +812,19 @@ def add_flow_def(name: str, fl_def: Callable[[FlowBuilder, DataScope], None]) ->
805
812
  return fl
806
813
 
807
814
 
815
+ def remove_flow(fl: Flow) -> None:
816
+ """
817
+ Remove a flow from the current process to free up resources.
818
+ After it's called, methods of the flow should no longer be called.
819
+
820
+ This will NOT touch the persistent backends of the flow.
821
+ """
822
+ _engine.remove_flow_context(fl.full_name)
823
+ fl._lazy_engine_flow = None # pylint: disable=protected-access
824
+ with _flows_lock:
825
+ del _flows[fl.name]
826
+
827
+
808
828
  def flow_def(
809
829
  name: str | None = None,
810
830
  ) -> Callable[[Callable[[FlowBuilder, DataScope], None]], Flow]:
cocoindex/setting.py CHANGED
@@ -44,12 +44,12 @@ class DatabaseConnectionSpec:
44
44
 
45
45
 
46
46
  @dataclass
47
- class DefaultExecutionOptions:
48
- """Default execution options."""
47
+ class GlobalExecutionOptions:
48
+ """Global execution options."""
49
49
 
50
- # The maximum number of concurrent inflight requests.
51
- source_max_inflight_rows: int | None = 256
52
- source_max_inflight_bytes: int | None = 1024 * 1024 * 1024
50
+ # The maximum number of concurrent inflight requests, shared among all sources from all flows.
51
+ source_max_inflight_rows: int | None = None
52
+ source_max_inflight_bytes: int | None = None
53
53
 
54
54
 
55
55
  def _load_field(
@@ -81,7 +81,7 @@ class Settings:
81
81
 
82
82
  database: DatabaseConnectionSpec | None = None
83
83
  app_namespace: str = ""
84
- default_execution_options: DefaultExecutionOptions | None = None
84
+ global_execution_options: GlobalExecutionOptions | None = None
85
85
 
86
86
  @classmethod
87
87
  def from_env(cls) -> Self:
@@ -110,14 +110,14 @@ class Settings:
110
110
  "COCOINDEX_SOURCE_MAX_INFLIGHT_BYTES",
111
111
  parse=int,
112
112
  )
113
- default_execution_options = DefaultExecutionOptions(**exec_kwargs)
113
+ global_execution_options = GlobalExecutionOptions(**exec_kwargs)
114
114
 
115
115
  app_namespace = os.getenv("COCOINDEX_APP_NAMESPACE", "")
116
116
 
117
117
  return cls(
118
118
  database=database,
119
119
  app_namespace=app_namespace,
120
- default_execution_options=default_execution_options,
120
+ global_execution_options=global_execution_options,
121
121
  )
122
122
 
123
123
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cocoindex
3
- Version: 0.1.64
3
+ Version: 0.1.65
4
4
  Requires-Dist: click>=8.1.8
5
5
  Requires-Dist: rich>=14.0.0
6
6
  Requires-Dist: python-dotenv>=1.1.0
@@ -1,13 +1,13 @@
1
- cocoindex-0.1.64.dist-info/METADATA,sha256=ByEFBlXrGkbESv0twsq2eLycjhTdkQKnE_EzQVIpWgQ,10136
2
- cocoindex-0.1.64.dist-info/WHEEL,sha256=tYU0YwShGV5a1IBa9K6b40tOXRGPW5TH008p3c7dncU,109
3
- cocoindex-0.1.64.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
- cocoindex-0.1.64.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- cocoindex/__init__.py,sha256=hDjehCjxRabFCW0RTt00JxnSAJIn9HeVoK4OjFbETsk,1910
6
- cocoindex/_engine.cpython-311-aarch64-linux-gnu.so,sha256=a6r52tacUnzRqxo_W26iQ7fbR3qdCMb8umOaJ6-TLUs,61287640
1
+ cocoindex-0.1.65.dist-info/METADATA,sha256=q_r8liwwqP1fcDFl0sNkTjty5ZZt6xbGEUFcpOOOR04,10136
2
+ cocoindex-0.1.65.dist-info/WHEEL,sha256=tYU0YwShGV5a1IBa9K6b40tOXRGPW5TH008p3c7dncU,109
3
+ cocoindex-0.1.65.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
+ cocoindex-0.1.65.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ cocoindex/__init__.py,sha256=TXK1FRqfm9DeDD7MycgDEfNutu8utM-dARQSurD98vc,1993
6
+ cocoindex/_engine.cpython-311-aarch64-linux-gnu.so,sha256=16C-8InM-eD_9sopRNgpuuipujEuv4ISa8JGpjlog4A,61386504
7
7
  cocoindex/auth_registry.py,sha256=1XqO7ibjmBBd8i11XSJTvTgdz8p1ptW-ZpuSgo_5zzk,716
8
8
  cocoindex/cli.py,sha256=-gp639JSyQN6YjnhGqCakIzYoSSqXxQMbxbkcYGP0QY,22359
9
9
  cocoindex/convert.py,sha256=qE1Ut_tAwX4wA4WqaWxpyj80-1t6WZ8Oi5_L9Mw5g4k,11393
10
- cocoindex/flow.py,sha256=Rb3ImrFa-TKYZXZnfcTj4ePUZXqKgJCzZR4OYHP6rlk,34207
10
+ cocoindex/flow.py,sha256=MFPtfJBVTjQ56d7vUn2LvtY30Vg4q2rY6nqvjjJL1kQ,35085
11
11
  cocoindex/functions.py,sha256=IBwvdPpGR-S5mk53HvHpT2GVs15MI9wQznxgOdxA0ac,3202
12
12
  cocoindex/index.py,sha256=j93B9jEvvLXHtpzKWL88SY6wCGEoPgpsQhEGHlyYGFg,540
13
13
  cocoindex/lib.py,sha256=f--9dAYd84CZosbDZqNW0oGbBLsY3dXiUTR1VrfQ_QY,817
@@ -15,7 +15,7 @@ cocoindex/llm.py,sha256=0ri8ZRg9_Zf2gyC5xuQ1Kq6kdZUO8r-A5WLnxit5S_4,448
15
15
  cocoindex/op.py,sha256=r_Usx7Jqh49Cck3tsYLx2vLRNUZArkQP_g7bIID6LPU,11809
16
16
  cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  cocoindex/runtime.py,sha256=bAdHYaXFWiiUWyAgzmKTeaAaRR0D_AmaqVCIdPO-v00,1056
18
- cocoindex/setting.py,sha256=FMNjer3YVmVyxLuGt6_DJ6vA1QH1mIo7oH0R51OLnk4,4714
18
+ cocoindex/setting.py,sha256=ADuv7RaWd9k-m3V0Cfy2jmaCt6DupJCviWdOm0CTiVw,4734
19
19
  cocoindex/setup.py,sha256=7uIHKN4FOCuoidPXcKyGTrkqpkl9luL49-6UcnMxYzw,3068
20
20
  cocoindex/sources.py,sha256=JCnOhv1w4o28e03i7yvo4ESicWYAhckkBg5bQlxNH4U,1330
21
21
  cocoindex/targets.py,sha256=Nfh_tpFd1goTnS_cxBjIs4j9zl3Z4Z1JomAQ1dl3Sic,2796
@@ -25,4 +25,4 @@ cocoindex/tests/test_optional_database.py,sha256=snAmkNa6wtOSaxoZE1HgjvL5v_ylitt
25
25
  cocoindex/tests/test_typing.py,sha256=t6UCYShcfonTfjBlGRWPiFGMZ8DGFfABXo6idekPoJE,14757
26
26
  cocoindex/typing.py,sha256=qQ-nSdkHzu8pSxfuR5sGGfoE8nCKqCDb0D9jbmxVt4M,12635
27
27
  cocoindex/utils.py,sha256=hUhX-XV6XGCtJSEIpBOuDv6VvqImwPlgBxztBTw7u0U,598
28
- cocoindex-0.1.64.dist-info/RECORD,,
28
+ cocoindex-0.1.65.dist-info/RECORD,,