This is an automated email from the ASF dual-hosted git repository.

xtsong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git

commit 96c2a9dcbe1e161f10dc10b34df367cea22f880f
Author: WenjinXie <[email protected]>
AuthorDate: Tue Sep 23 16:47:36 2025 +0800

    [runtime] Avoid manually adding the framework jars in user code.
---
 python/flink_agents/api/execution_environment.py             |  3 +++
 .../examples/integrate_datastream_with_agent_example.py      | 11 -----------
 .../examples/integrate_table_with_agent_example.py           | 11 -----------
 .../examples/integrate_table_with_react_agent_example.py     | 11 -----------
 .../examples/quickstart/product_improve_suggestion.py        | 11 -----------
 .../examples/quickstart/product_review_analysis.py           | 12 ------------
 6 files changed, 3 insertions(+), 56 deletions(-)

diff --git a/python/flink_agents/api/execution_environment.py 
b/python/flink_agents/api/execution_environment.py
index 57d32e3..cda5e41 100644
--- a/python/flink_agents/api/execution_environment.py
+++ b/python/flink_agents/api/execution_environment.py
@@ -19,6 +19,7 @@ import importlib
 from abc import ABC, abstractmethod
 from typing import Any, Callable, Dict, List, Type
 
+from importlib_resources import files
 from pyflink.common import TypeInformation
 from pyflink.datastream import DataStream, KeySelector, 
StreamExecutionEnvironment
 from pyflink.table import Schema, StreamTableEnvironment, Table
@@ -134,6 +135,8 @@ class AgentsExecutionEnvironment(ABC):
                 "flink_agents.runtime.local_execution_environment"
             ).create_instance(env=env, **kwargs)
         else:
+            for path in files("flink_agents.lib").iterdir():
+                env.add_jars(f"file://{path}")
             return importlib.import_module(
                 "flink_agents.runtime.remote_execution_environment"
             ).create_instance(env=env, **kwargs)
diff --git 
a/python/flink_agents/examples/integrate_datastream_with_agent_example.py 
b/python/flink_agents/examples/integrate_datastream_with_agent_example.py
index 768e155..8e03d69 100644
--- a/python/flink_agents/examples/integrate_datastream_with_agent_example.py
+++ b/python/flink_agents/examples/integrate_datastream_with_agent_example.py
@@ -45,17 +45,6 @@ current_dir = Path(__file__).parent
 if __name__ == "__main__":
     env = StreamExecutionEnvironment.get_execution_environment()
 
-    # should compile flink-agents jars before run this example.
-    env.add_jars(
-        
f"file:///{current_dir}/../../../runtime/target/flink-agents-runtime-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../plan/target/flink-agents-plan-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../api/target/flink-agents-api-0.1-SNAPSHOT.jar"
-    )
-
     env.set_runtime_mode(RuntimeExecutionMode.STREAMING)
     env.set_parallelism(1)
 
diff --git a/python/flink_agents/examples/integrate_table_with_agent_example.py 
b/python/flink_agents/examples/integrate_table_with_agent_example.py
index 07b60c0..2069d51 100644
--- a/python/flink_agents/examples/integrate_table_with_agent_example.py
+++ b/python/flink_agents/examples/integrate_table_with_agent_example.py
@@ -51,17 +51,6 @@ class MyKeySelector(KeySelector):
 if __name__ == "__main__":
     env = StreamExecutionEnvironment.get_execution_environment()
 
-    # should compile flink-agents jars before run this example.
-    env.add_jars(
-        
f"file:///{current_dir}/../../../runtime/target/flink-agents-runtime-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../plan/target/flink-agents-plan-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../api/target/flink-agents-api-0.1-SNAPSHOT.jar"
-    )
-
     env.set_runtime_mode(RuntimeExecutionMode.STREAMING)
     env.set_parallelism(1)
 
diff --git 
a/python/flink_agents/examples/integrate_table_with_react_agent_example.py 
b/python/flink_agents/examples/integrate_table_with_react_agent_example.py
index 1c5ae43..8d3d0a5 100644
--- a/python/flink_agents/examples/integrate_table_with_react_agent_example.py
+++ b/python/flink_agents/examples/integrate_table_with_react_agent_example.py
@@ -55,17 +55,6 @@ current_dir = Path(__file__).parent
 if __name__ == "__main__":
     stream_env = StreamExecutionEnvironment.get_execution_environment()
 
-    # should compile flink-agents jars before run this example.
-    stream_env.add_jars(
-        
f"file:///{current_dir}/../../../runtime/target/flink-agents-runtime-0.1-SNAPSHOT.jar"
-    )
-    stream_env.add_jars(
-        
f"file:///{current_dir}/../../../plan/target/flink-agents-plan-0.1-SNAPSHOT.jar"
-    )
-    stream_env.add_jars(
-        
f"file:///{current_dir}/../../../api/target/flink-agents-api-0.1-SNAPSHOT.jar"
-    )
-
     stream_env.set_parallelism(1)
 
     t_env = 
StreamTableEnvironment.create(stream_execution_environment=stream_env)
diff --git 
a/python/flink_agents/examples/quickstart/product_improve_suggestion.py 
b/python/flink_agents/examples/quickstart/product_improve_suggestion.py
index 1f50221..129027e 100644
--- a/python/flink_agents/examples/quickstart/product_improve_suggestion.py
+++ b/python/flink_agents/examples/quickstart/product_improve_suggestion.py
@@ -97,17 +97,6 @@ def main() -> None:
         request_timeout=120,
     )
 
-    # TODO: Remove this once https://github.com/apache/flink-agents/issues/173 
is fixed.
-    # Add required flink-agents jars to the environment.
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../runtime/target/flink-agents-runtime-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../plan/target/flink-agents-plan-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../api/target/flink-agents-api-0.1-SNAPSHOT.jar"
-    )
 
     # Read product reviews from a text file as a streaming source.
     # Each line in the file should be a JSON string representing a 
ProductReview.
diff --git a/python/flink_agents/examples/quickstart/product_review_analysis.py 
b/python/flink_agents/examples/quickstart/product_review_analysis.py
index 560a5b2..0ef06de 100644
--- a/python/flink_agents/examples/quickstart/product_review_analysis.py
+++ b/python/flink_agents/examples/quickstart/product_review_analysis.py
@@ -54,18 +54,6 @@ def main() -> None:
         request_timeout=120,
     )
 
-    # TODO: Remove this once https://github.com/apache/flink-agents/issues/173 
is fixed.
-    # Add required flink-agents jars to the environment.
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../runtime/target/flink-agents-runtime-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../plan/target/flink-agents-plan-0.1-SNAPSHOT.jar"
-    )
-    env.add_jars(
-        
f"file:///{current_dir}/../../../../api/target/flink-agents-api-0.1-SNAPSHOT.jar"
-    )
-
     # Read product reviews from a text file as a streaming source.
     # Each line in the file should be a JSON string representing a 
ProductReview.
     product_review_stream = env.from_source(

Reply via email to