Export google_a2a as a python module instead of common and agents#169
Export google_a2a as a python module instead of common and agents#169djsamseng wants to merge 9 commits intoa2aproject:mainfrom
Conversation
|
@rajeshvelicheti any chance I could grab you to take a look at this before too many more conflicts arise with samples getting added? This will also allow us to start writing tests as well as a Python A2A tutorial |
a88375c to
3db2eea
Compare
|
Rebased and made changes to make this PR work again after the PRs that have been merged to main in the meantime. Test Plan:
|
- Replace imports
```bash
find src -name '*.py' -exec sed -i 's/^import common/import google_a2a.common/' {} +
find src -name '*.py' -exec sed -i 's/^import hosts/import google_a2a.hosts/' {} +
find src -name '*.py' -exec sed -i 's/^import agents/import google_a2a.agents/' {} +
find src -name '*.py' -exec sed -i 's/^from common/from google_a2a.common/' {} +
find src -name '*.py' -exec sed -i 's/^from agents/from google_a2a.agents/' {} +
find src -name '*.py' -exec sed -i 's/^from hosts/from google_a2a.hosts/' {} +
```
- Double check (note: some manual fixups may be needed due to spaces)
```bash
git grep -n -i "import common"
git grep -n -i "import hosts"
git grep -n -i "import agents"
git grep -n -i "from common"
git grep -n -i "from hosts"
git grep -n -i "from agents"
```
find . -name '*.md' -exec sed -i 's,/samples/python/common,/samples/python/src/google_a2a/common,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/common,/samples/python/src/google_a2a/common,' {} +
find . -name '*.md' -exec sed -i 's,/samples/python/hosts,/samples/python/src/google_a2a/hosts,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/hosts,/samples/python/src/google_a2a/hosts,' {} +
find . -name '*.md' -exec sed -i 's,/samples/python/agents,/samples/python/src/google_a2a/agents,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/agents,/samples/python/src/google_a2a/agents,' {} +
find . -name '*.pyproject.toml' -exec sed -i 's/a2a-samples/google-a2a/' {} +
3db2eea to
5a6ceda
Compare
|
Rebased and retested. Here's the full description of changes StepsMove filesmkdir src
mkdir src/google_a2a
git mv -f common src/google_a2a
git mv -f hosts src/google_a2a
git mv -f agents src/google_a2aUpdate pyproject.toml[project]
name = "google-a2a"
description = "Agent2Agent modules and samples"
[tool.hatch.build.targets.wheel]
packages = ["src/google_a2a"]
[tool.uv.workspace]
members = [
"src/google_a2a/agents/crewai",
"src/google_a2a/agents/google_adk",
"src/google_a2a/agents/langgraph",
"src/google_a2a/hosts/cli",
"src/google_a2a/hosts/multiagent",
"src/google_a2a/agents/llama_index_file_chat",
"src/google_a2a/agents/semantickernel",
]Replace importsfind src -name '*.py' -exec sed -i 's/^import common/import google_a2a.common/' {} +
find src -name '*.py' -exec sed -i 's/^import hosts/import google_a2a.hosts/' {} +
find src -name '*.py' -exec sed -i 's/^import agents/import google_a2a.agents/' {} +
find src -name '*.py' -exec sed -i 's/^from common/from google_a2a.common/' {} +
find src -name '*.py' -exec sed -i 's/^from agents/from google_a2a.agents/' {} +
find src -name '*.py' -exec sed -i 's/^from hosts/from google_a2a.hosts/' {} +
git grep -n -i "import common"
git grep -n -i "import hosts"
git grep -n -i "import agents"
git grep -n -i "from common"
git grep -n -i "from hosts"
git grep -n -i "from agents"Replace referencesfind . -name '*.md' -exec sed -i 's,/samples/python/common,/samples/python/src/google_a2a/common,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/common,/samples/python/src/google_a2a/common,' {} +
find . -name '*.md' -exec sed -i 's,/samples/python/hosts,/samples/python/src/google_a2a/hosts,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/hosts,/samples/python/src/google_a2a/hosts,' {} +
find . -name '*.md' -exec sed -i 's,/samples/python/agents,/samples/python/src/google_a2a/agents,' {} +
find . -name '*.txt' -exec sed -i 's,/samples/python/agents,/samples/python/src/google_a2a/agents,' {} +Replace a2a-samplesfind . -name '*.pyproject.toml' -exec sed -i 's/a2a-samples/google-a2a/' {} +git grep -n -i a2a-samplesCreate quickstart example
Expose cli as a script
def main():
asyncio.run(cli())
if __name__ == "__main__":
main()Test Plan
|
|
if this isn't merged in - the tutorial doesn't line up yet right? https://google.github.io/A2A/tutorials/python/7-interact-with-server/ I'm trying to run the cli from the my-project folder instead of having to pull the entire repo down. |
Interesting - it was originally mentioned in the tutorial but now has overwritten https://github.com/google/A2A/pull/202/files#diff-1e612e5d30745859d2821e04adb1bd652320e755b78a814c2d24db71301cd0b4R37 The git history for the gh-pages branch also got force rewritten 😥 |
| version = "0.2.0" | ||
| description = "Agent2Agent modules and samples" | ||
| readme = "README.md" | ||
| requires-python = ">=3.12" |
There was a problem hiding this comment.
@djsamseng would it be possible for this to use >=3.11 ?
(see #406 )
There was a problem hiding this comment.
Happy to - once we get a green light I’ll rebase as well.
|
anything blocking a review here? |
|
See #423 for updates on official A2A SDK launch
|
|
@djsamseng Thank you for this contribution, however much of it won't be needed going forward once the official SDK is released. There is an early version of it in |
|
This PR is no longer needed due to the Python SDK being published. |
Sets up the file structure correctly to allow for the modules to be imported with a proper namespace.
Previously developers would have to
Now developers can
This will allow us to further enhance this module to become production ready in the future. And in the meantime it allows those of us experimenting with A2A to avoid namespace clashes.
See the samples/python/README.md for an example setup.
Addresses the issues raised in this comment
Test Plan:
uv add /path/to/A2A/samples/pythonand was able toimport google_a2a.common.serverand create and run anA2AServer. This verifies the server does in fact run.