From 513f8716ca0ba1e6b2815f09b2f63b38a2d147db Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 9 Dec 2024 15:37:24 -0800 Subject: [PATCH 01/13] enable windows on intergration test --- .github/workflows/dotnet-build.yml | 12 ++++-------- dotnet/global.json | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index e70a943ccd7e..345aa328afcc 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -108,8 +108,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ ubuntu-latest] - version: [ net8.0 ] + os: [ ubuntu-latest, windows-latest ] needs: build defaults: run: @@ -134,9 +133,6 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' - - name: Install Temp Global.JSON - run: | - echo "{\"sdk\": {\"version\": \"9.0.101\"}}" > global.json - name: Install .NET Aspire workload run: dotnet workload install aspire - name: Install dev certs @@ -149,9 +145,9 @@ jobs: echo "Build AutoGen" dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true - name: Integration Test - run: dotnet --version && dotnet test --no-build -bl --configuration Release --filter type=integration - - name: Restore the global.json - run: rm global.json && git checkout -- global.json + run: | + dotnet --version + dotnet test --no-build -bl --configuration Release --filter type=integration aot-test: # this make sure the AutoGen.Core is aot compatible strategy: diff --git a/dotnet/global.json b/dotnet/global.json index 4f9e9b79a15a..93e6dbdd448a 100644 --- a/dotnet/global.json +++ b/dotnet/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.401", + "version": "9.0.101", "rollForward": "latestMinor" } } From 9b8d80769991be514ceebe03aa87a143b3bb48d6 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 9 Dec 2024 15:40:44 -0800 Subject: [PATCH 02/13] update --- .github/workflows/dotnet-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 345aa328afcc..583235dbc46f 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -87,7 +87,7 @@ jobs: - name: Setup .NET 8.0 uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + global-json-file: dotnet/global.json - name: Restore dependencies run: | # dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config From e174a69dd7261a983c8e6547a12ebbc4aacd79cb Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 9 Dec 2024 15:42:42 -0800 Subject: [PATCH 03/13] revert global.json --- .github/workflows/dotnet-build.yml | 2 +- dotnet/global.json | 2 +- dotnet/samples/Hello/HelloAgent/appsettings.json | 4 ++-- .../samples/xlang/hello_python_agent/hello_python_agent.py | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 583235dbc46f..78a539e612c8 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -84,7 +84,7 @@ jobs: - name: Prepare python venv run: | source ${{ github.workspace }}/python/.venv/bin/activate - - name: Setup .NET 8.0 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: global-json-file: dotnet/global.json diff --git a/dotnet/global.json b/dotnet/global.json index 93e6dbdd448a..4f9e9b79a15a 100644 --- a/dotnet/global.json +++ b/dotnet/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.101", + "version": "8.0.401", "rollForward": "latestMinor" } } diff --git a/dotnet/samples/Hello/HelloAgent/appsettings.json b/dotnet/samples/Hello/HelloAgent/appsettings.json index 3bb8d882550c..420ccf5edb19 100644 --- a/dotnet/samples/Hello/HelloAgent/appsettings.json +++ b/dotnet/samples/Hello/HelloAgent/appsettings.json @@ -1,9 +1,9 @@ { "Logging": { "LogLevel": { - "Default": "Warning", + "Default": "Information", "Microsoft": "Warning", "Microsoft.Orleans": "Warning" } } - } \ No newline at end of file + } diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py index c50aacedd5b9..75e2a467020a 100644 --- a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py +++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py @@ -63,9 +63,12 @@ async def main() -> None: topic_id=DefaultTopicId("agents.Output", "HelloAgents/python"), sender=AgentId("HelloAgents", "python"), ) - await runtime.stop_when_signal() - # await runtime.stop_when_idle() + try: + await runtime._read_task + except KeyboardInterrupt: + print("KeyboardInterrupt") + await runtime.stop() if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) From bc06c92d0a2831ea5c931d6abf64e3bd9e477747 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Tue, 10 Dec 2024 16:11:53 -0800 Subject: [PATCH 04/13] extend to 15 seconds --- .../HelloAppHostIntegrationTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/test/Microsoft.AutoGen.Integration.Tests/HelloAppHostIntegrationTests.cs b/dotnet/test/Microsoft.AutoGen.Integration.Tests/HelloAppHostIntegrationTests.cs index dea3eec41218..5f465a4c51b1 100644 --- a/dotnet/test/Microsoft.AutoGen.Integration.Tests/HelloAppHostIntegrationTests.cs +++ b/dotnet/test/Microsoft.AutoGen.Integration.Tests/HelloAppHostIntegrationTests.cs @@ -42,8 +42,8 @@ public async Task AppHostLogsHelloAgentE2E(TestEndpoints testEndpoints) await app.WaitForResource(ResourceName, TargetState).WaitAsync(timeout); } } - //sleep 5 seconds to make sure the app is running - await Task.Delay(5000); + //sleep 15 seconds to make sure the app is running + await Task.Delay(15000); app.EnsureNoErrorsLogged(); app.EnsureLogContains("HelloAgents said Goodbye"); app.EnsureLogContains("Wild Hello from Python!"); From ce4df8d0eb6303b40a5497ac7e20761b9e46a4b7 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Tue, 10 Dec 2024 16:28:13 -0800 Subject: [PATCH 05/13] format --- .../samples/xlang/hello_python_agent/hello_python_agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py index 75e2a467020a..6051f431408b 100644 --- a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py +++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py @@ -70,6 +70,7 @@ async def main() -> None: print("KeyboardInterrupt") await runtime.stop() + if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) agnext_logger.setLevel(logging.DEBUG) From 7045cf6e328d1beb2d512a5bcdb321aeb909f1ef Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Tue, 10 Dec 2024 23:57:07 -0800 Subject: [PATCH 06/13] update --- .github/workflows/dotnet-build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 78a539e612c8..5d9d4546aa59 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -126,9 +126,6 @@ jobs: python-version: "3.11" - run: uv sync --locked --all-extras working-directory: ./python - - name: Prepare python venv - run: | - source ${{ github.workspace }}/python/.venv/bin/activate - name: Setup .NET 9.0 uses: actions/setup-dotnet@v4 with: From 274261840ec2f67a6dd20023df408c2404f77257 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 00:01:45 -0800 Subject: [PATCH 07/13] add stop_when_shutdown --- .../xlang/hello_python_agent/hello_python_agent.py | 8 ++------ .../src/autogen_ext/runtimes/grpc/_worker_runtime.py | 8 ++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py index 6051f431408b..51b12e405702 100644 --- a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py +++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py @@ -63,12 +63,8 @@ async def main() -> None: topic_id=DefaultTopicId("agents.Output", "HelloAgents/python"), sender=AgentId("HelloAgents", "python"), ) - - try: - await runtime._read_task - except KeyboardInterrupt: - print("KeyboardInterrupt") - await runtime.stop() + + await runtime.stop_when_shutdown() if __name__ == "__main__": diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py index 703f88a53be2..a4afb647641f 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py @@ -298,6 +298,14 @@ async def stop(self) -> None: await self._read_task except asyncio.CancelledError: pass + + async def stop_when_shutdown(self) -> None: + """Stop the runtime when Ctrl+C or SIGTERM is received.""" + try: + await self._read_task + except KeyboardInterrupt: + logger.info("Received exit signal, shutting down gracefully...") + await self.stop() async def stop_when_signal(self, signals: Sequence[signal.Signals] = (signal.SIGTERM, signal.SIGINT)) -> None: """Stop the runtime when a signal is received.""" From 6b60a862ffbacdf9ef2141d52f54203ad848d695 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 00:02:41 -0800 Subject: [PATCH 08/13] prompt exception when on windows --- .../src/autogen_ext/runtimes/grpc/_worker_runtime.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py index a4afb647641f..7e5e9e734dd0 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py @@ -3,6 +3,7 @@ import json import logging import signal +import sys import uuid import warnings from asyncio import Future, Task @@ -309,6 +310,10 @@ async def stop_when_shutdown(self) -> None: async def stop_when_signal(self, signals: Sequence[signal.Signals] = (signal.SIGTERM, signal.SIGINT)) -> None: """Stop the runtime when a signal is received.""" + + # check if it's running on linux or windows + if sys.platform == "win32": + raise NotImplementedError("Signal handling is not supported on Windows. Please use stop_when_shutdown instead.") loop = asyncio.get_running_loop() shutdown_event = asyncio.Event() From df9d1d50afbf0c8357c37d7bc074884ce21d8b7a Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 10:21:09 -0800 Subject: [PATCH 09/13] format --- .../samples/xlang/hello_python_agent/hello_python_agent.py | 2 +- .../src/autogen_ext/runtimes/grpc/_worker_runtime.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py index 51b12e405702..01a02cf637e8 100644 --- a/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py +++ b/python/packages/autogen-core/samples/xlang/hello_python_agent/hello_python_agent.py @@ -63,7 +63,7 @@ async def main() -> None: topic_id=DefaultTopicId("agents.Output", "HelloAgents/python"), sender=AgentId("HelloAgents", "python"), ) - + await runtime.stop_when_shutdown() diff --git a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py index 7e5e9e734dd0..1a4e748e00ab 100644 --- a/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py +++ b/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py @@ -299,7 +299,7 @@ async def stop(self) -> None: await self._read_task except asyncio.CancelledError: pass - + async def stop_when_shutdown(self) -> None: """Stop the runtime when Ctrl+C or SIGTERM is received.""" try: @@ -313,7 +313,9 @@ async def stop_when_signal(self, signals: Sequence[signal.Signals] = (signal.SIG # check if it's running on linux or windows if sys.platform == "win32": - raise NotImplementedError("Signal handling is not supported on Windows. Please use stop_when_shutdown instead.") + raise NotImplementedError( + "Signal handling is not supported on Windows. Please use stop_when_shutdown instead." + ) loop = asyncio.get_running_loop() shutdown_event = asyncio.Event() From e4768d98a25261f6f6f82517558322f51eaefe67 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 12:44:44 -0800 Subject: [PATCH 10/13] check certs --- .github/workflows/dotnet-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 5d9d4546aa59..69411fc47d2a 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -132,8 +132,8 @@ jobs: dotnet-version: '9.0.x' - name: Install .NET Aspire workload run: dotnet workload install aspire - - name: Install dev certs - run: dotnet --version && dotnet dev-certs https --trust + - name: Check dev certs + run: dotnet --version && dotnet dev-certs https --check - name: Restore dependencies run: | dotnet restore -bl From d4d1a580fa11313db5d0986872d8a21bf611445a Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 13:36:59 -0800 Subject: [PATCH 11/13] enable trust --- .github/workflows/dotnet-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 69411fc47d2a..ccf685a5499e 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -133,7 +133,7 @@ jobs: - name: Install .NET Aspire workload run: dotnet workload install aspire - name: Check dev certs - run: dotnet --version && dotnet dev-certs https --check + run: dotnet --version && dotnet dev-certs https --check --trust - name: Restore dependencies run: | dotnet restore -bl From 4a362b2696edf26dfdd2cd595507b4c34f001868 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Wed, 11 Dec 2024 13:41:27 -0800 Subject: [PATCH 12/13] udpate --- .github/workflows/dotnet-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index ccf685a5499e..9aaea29e55cd 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -132,8 +132,9 @@ jobs: dotnet-version: '9.0.x' - name: Install .NET Aspire workload run: dotnet workload install aspire - - name: Check dev certs + - name: Check dev certs when running on linux run: dotnet --version && dotnet dev-certs https --check --trust + if: runner.os == 'Linux' - name: Restore dependencies run: | dotnet restore -bl From dfb76020947f8d7b2206b44b387fba9077561874 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Thu, 12 Dec 2024 12:35:29 -0800 Subject: [PATCH 13/13] Update dotnet-build.yml --- .github/workflows/dotnet-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 9aaea29e55cd..4a543d70ddc4 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -133,7 +133,7 @@ jobs: - name: Install .NET Aspire workload run: dotnet workload install aspire - name: Check dev certs when running on linux - run: dotnet --version && dotnet dev-certs https --check --trust + run: dotnet --version && dotnet dev-certs https --trust if: runner.os == 'Linux' - name: Restore dependencies run: |