Skip to content

Commit b186833

Browse files
authored
cleanup: remove deprecated @cocoindex.main_fn (#695)
1 parent 21947c6 commit b186833

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

docs/docs/core/cli.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ CocoIndex CLI supports the following global options:
4747
* `--version`: Show the CocoIndex version and exit.
4848
* `--help`: Show the main help message and exit.
4949

50-
:::caution Deprecated Usage
51-
52-
The old method of invoking the CLI using `python main.py cocoindex ...` via the `@cocoindex.main_fn()` decorator is now deprecated. Please remove `@cocoindex.main_fn()` from your scripts and use the standalone cocoindex command as described.
53-
54-
:::
55-
5650
## Subcommands
5751

5852
The following subcommands are available:

python/cocoindex/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .flow import EvaluateAndDumpOptions, GeneratedField
1313
from .flow import FlowLiveUpdater, FlowLiveUpdaterOptions
1414
from .flow import update_all_flows_async, setup_all_flows, drop_all_flows
15-
from .lib import init, start_server, stop, main_fn
15+
from .lib import init, start_server, stop
1616
from .llm import LlmSpec, LlmApiType
1717
from .index import VectorSimilarityMetric, VectorIndexDef, IndexOptions
1818
from .setting import DatabaseConnectionSpec, Settings, ServerSettings
@@ -59,7 +59,6 @@
5959
"init",
6060
"start_server",
6161
"stop",
62-
"main_fn",
6362
# LLM
6463
"LlmSpec",
6564
"LlmApiType",

python/cocoindex/lib.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,3 @@ def start_server(settings: setting.ServerSettings) -> None:
3030
def stop() -> None:
3131
"""Stop the cocoindex library."""
3232
_engine.stop()
33-
34-
35-
def main_fn(
36-
settings: Any | None = None,
37-
cocoindex_cmd: str | None = None,
38-
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
39-
"""
40-
DEPRECATED: The @cocoindex.main_fn() decorator is obsolete and has no effect.
41-
It will be removed in a future version, which will cause an AttributeError.
42-
43-
Please remove this decorator from your code and use the standalone 'cocoindex' CLI.
44-
See the updated CLI usage examples in the warning message.
45-
"""
46-
warnings.warn(
47-
"\n\n"
48-
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
49-
"CRITICAL DEPRECATION NOTICE from CocoIndex:\n"
50-
"The @cocoindex.main_fn() decorator in your script is DEPRECATED and IGNORED.\n"
51-
"It provides NO functionality and will be REMOVED entirely in a future version.\n"
52-
"If not removed, your script will FAIL with an AttributeError in the future.\n\n"
53-
"ACTION REQUIRED: Please REMOVE @cocoindex.main_fn() from your Python script.\n\n"
54-
"To use CocoIndex, invoke the standalone 'cocoindex' CLI."
55-
" Examples of new CLI usage:\n\n"
56-
" To list flows from 'main.py' (previously 'python main.py cocoindex ls'):\n"
57-
" cocoindex ls main.py\n\n"
58-
" To list all persisted flows (previously 'python main.py cocoindex ls --all'):\n"
59-
" cocoindex ls\n\n"
60-
" To show 'MyFlow' defined in 'main.py' (previously 'python main.py cocoindex show MyFlow'):\n"
61-
" cocoindex show main.py:MyFlow\n\n"
62-
" To update all flows in 'my_package.flows_module':\n"
63-
" cocoindex update my_package.flows_module\n\n"
64-
" To update 'SpecificFlow' in 'my_package.flows_module':\n"
65-
" cocoindex update my_package.flows_module:SpecificFlow\n\n"
66-
"See cocoindex <command> --help for more details.\n"
67-
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n",
68-
DeprecationWarning,
69-
stacklevel=2,
70-
)
71-
72-
def _main_wrapper(fn: Callable[..., Any]) -> Callable[..., Any]:
73-
return fn
74-
75-
return _main_wrapper

0 commit comments

Comments
 (0)