Skip to content

Feat: add python sdk for Agones game server#4496

Open
hiromesh wants to merge 6 commits intoagones-dev:mainfrom
hiromesh:feature/python-sdk
Open

Feat: add python sdk for Agones game server#4496
hiromesh wants to merge 6 commits intoagones-dev:mainfrom
hiromesh:feature/python-sdk

Conversation

@hiromesh
Copy link
Copy Markdown

@hiromesh hiromesh commented Apr 1, 2026

What type of PR is this?

/kind feature

What this PR does / Why we need it:

Adds a Python SDK for the Agones game server platform, providing a gRPC client for communicating with the Agones sidecar.

The SDK follows the same architecture and API patterns as the existing Go, Rust, and Node.js SDKs:

  • Core SDK: GameServer lifecycle management (Ready, Allocate, Shutdown, Reserve, Health, GetGameServer, WatchGameServer, SetLabel, SetAnnotation)
  • Alpha SDK: Player tracking (PlayerConnect, PlayerDisconnect, capacity/count management)
  • Beta SDK: Counters and Lists (get/set/increment/decrement counters, get/set/append/delete lists)

Commits:

  1. feat: add initial Python SDK for Agones game server
    • agones/sdk.py, agones/alpha.py, agones/beta.py — SDK implementation
    • agones/_generated/ — generated gRPC/protobuf code
    • generate.sh — proto code generation script (strips HTTP/swagger annotations)
    • pyproject.toml — package configuration
    • tests/test_sdk.py, tests/test_alpha.py, tests/test_beta.py — 37 unit tests
  2. docs: add Python Client SDK documentation and update README
    • site/content/en/docs/Guides/Client SDKs/python.md — full SDK documentation page
    • site/content/en/docs/Guides/Client SDKs/_index.md — added Python to SDK index
    • sdks/README.md — added Python entry
    • sdks/python/README.md — simplified to point to site docs
  3. feat: add Python SDK Dockerfile and scripts
    • build/build-sdk-images/python/Dockerfile — Docker build image
    • build/build-sdk-images/python/gen.sh — code generation entrypoint
    • build/build-sdk-images/python/test.sh — test runner entrypoint
    • build/includes/sdk.mk — added Python targets and conformance test
    • build/scripts/sdk-update-version/main.go — added pyproject.toml to version update list

Testing:

$ pytest tests/ -v
37 passed in 0.19s

All tests use unittest.mock.MagicMock to mock gRPC stubs (same approach as Go's sdkMock and Node.js's spyOn).

Which issue(s) this PR fixes:

None — new feature.

Special notes for your reviewer:

  • The generated gRPC code (agones/_generated/) is checked in, same approach as the Node.js SDK
  • generate.sh strips HTTP/swagger annotations from proto files before compilation to avoid unnecessary runtime dependencies
  • Conformance test port allocation: GRPC 9006 / HTTP 9106 (no conflict with existing SDKs)

hiromesh added 3 commits April 1, 2026 14:57
- Introduced core SDK functionality for managing GameServer lifecycle, including methods for connecting, marking readiness, and handling player connections.
- Implemented Alpha and Beta features for player tracking and counters/lists management.
- Added gRPC code generation script and necessary configuration files.
- Included README documentation for installation and usage instructions.
- Created .gitignore to exclude unnecessary files from version control.

Signed-off-by: hiromesh <417969567@qq.com>
- Added Python Client SDK documentation with installation and usage instructions.
- Updated README to include a link to the new Python Client SDK.
- Enhanced the main SDK documentation index to reference the Python SDK.

Signed-off-by: hiromesh <417969567@qq.com>
- Introduced Dockerfile for building Python SDK images, including installation of Python and necessary packages.
- Added code generation script (gen.sh) for setting up a Python virtual environment and installing grpcio-tools.
- Included test script (test.sh) for running pytest with required dependencies.
- Updated Makefile to support Python SDK commands for generation and conformance testing.

Signed-off-by: hiromesh <417969567@qq.com>
@github-actions github-actions bot added kind/feature New features for Agones size/XL labels Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link
Copy Markdown
Collaborator

@markmandel markmandel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge PR 😄 so tough to review - but let's see if it passes CI at least!

@@ -0,0 +1,23 @@
# Copyright 2026 Google LLC All Rights Reserved.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to have the new CNCF header, but we don't quite know what that is yet 😄 bear with us.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤨

@markmandel
Copy link
Copy Markdown
Collaborator

/gcbrun

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 4cc02a9e-8564-4474-9261-5fdda1e658b3

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

- Replaced sed commands with a Python script to modify import statements for relative imports in generated gRPC files.
- Removed obsolete license classifier from pyproject.toml.

Signed-off-by: hiromesh <417969567@qq.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@hiromesh
Copy link
Copy Markdown
Author

hiromesh commented Apr 2, 2026

/gcbrun

@hiromesh
Copy link
Copy Markdown
Author

hiromesh commented Apr 2, 2026

/gcbrun

found the issue: generate.sh was using sed -i '' (macos-only syntax) which fails on linux.
fixed by replacing with a portable python snippet.

@markmandel
Copy link
Copy Markdown
Collaborator

/gcbrun

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: c8baa8f7-c622-4b89-9105-9eee017856f7

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

- Introduced a new test script (sdktest.sh) for setting up a Python virtual environment and running the Agones SDK client.
- Added a comprehensive Python client implementation (testSDKClient.py) for managing player connections, counters, and lists within the Agones game server.

Signed-off-by: hiromesh <417969567@qq.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@hiromesh
Copy link
Copy Markdown
Author

hiromesh commented Apr 3, 2026

/gcbrun

thanks for triggering the build — really helpful!

found the issue: the missing sdktest.sh + conformance test client which the sdk conformance step requires.

fix is pushed : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New features for Agones size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants