diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index e70a943ccd7e..4a543d70ddc4 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -84,10 +84,10 @@ 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: - 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 @@ -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: @@ -127,20 +126,15 @@ 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: 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 + - name: Check dev certs when running on linux run: dotnet --version && dotnet dev-certs https --trust + if: runner.os == 'Linux' - name: Restore dependencies run: | dotnet restore -bl @@ -149,9 +143,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/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/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!"); 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..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,8 +63,8 @@ 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() + + 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 d2bf41ce0d1f..1cc86ca78c70 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 @@ -299,8 +300,22 @@ async def stop(self) -> None: 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.""" + + # 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()