Repository navigation
feat(store)!: a version named on a put must be the next one #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
27fa9d9
feat(store): let a versioned put require the version it replaces
earakely-scale b7c8ab0
feat(store)!: a version named on a put must be the next one
earakely-scale 4dc87ca
fix(store): FileArtifact.put and put_bytes publish when another write…
earakely-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """A2AAgent.put with a version: it lands on exactly that version, which must be the agent's next.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from agent_env.a2a_agent import A2AAgent | ||
| from agent_env.artifact.artifacts.docker_image import DockerImageArtifact | ||
| from agent_env.artifact.store import get_artifact_store | ||
| from agent_env.store.base import ConcurrentModificationError | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def image(local_stores): | ||
| return get_artifact_store().put_document(DockerImageArtifact( | ||
| id="agent__agent_image", description="d", image_name="ghcr.io/acme/agent:1", tar_gz_s3_url="s3://b/x")) | ||
|
|
||
|
|
||
| def test_a_put_naming_the_next_version_lands_on_it(image): | ||
| assert A2AAgent.put(id="agent", docker_image_artifact=image, version=1).version == 1 | ||
| assert A2AAgent.put(id="agent", docker_image_artifact=image, version=2).version == 2 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("version", [2, 5]) | ||
| def test_a_put_naming_another_version_writes_nothing(image, version): | ||
| A2AAgent.put(id="agent", docker_image_artifact=image) | ||
| A2AAgent.put(id="agent", docker_image_artifact=image, metadata={"by": "other"}) | ||
|
|
||
| with pytest.raises(ConcurrentModificationError, match=f"at version 2, so its next version is 3, not {version}"): | ||
| A2AAgent.put(id="agent", docker_image_artifact=image, version=version, metadata={"by": "stale"}) | ||
|
|
||
| latest = A2AAgent.get("agent") | ||
| assert latest.version == 2 and latest.metadata["by"] == "other" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.