Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/runloop_api_client/sdk/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ async def create_from_npm(
self,
*,
package_name: str,
npm_version: Optional[str] = None,
registry_url: Optional[str] = None,
agent_setup: Optional[list[str]] = None,
**params: Unpack[SDKAgentCreateParams],
Expand All @@ -608,8 +607,6 @@ async def create_from_npm(

:param package_name: NPM package name
:type package_name: str
:param npm_version: NPM version constraint, defaults to None
:type npm_version: Optional[str], optional
:param registry_url: NPM registry URL, defaults to None
:type registry_url: Optional[str], optional
:param agent_setup: Setup commands to run after installation, defaults to None
Expand All @@ -625,8 +622,6 @@ async def create_from_npm(
)

npm_config: Npm = {"package_name": package_name}
if npm_version is not None:
npm_config["npm_version"] = npm_version
if registry_url is not None:
npm_config["registry_url"] = registry_url
if agent_setup is not None:
Expand All @@ -639,7 +634,6 @@ async def create_from_pip(
self,
*,
package_name: str,
pip_version: Optional[str] = None,
registry_url: Optional[str] = None,
agent_setup: Optional[list[str]] = None,
**params: Unpack[SDKAgentCreateParams],
Expand All @@ -648,8 +642,6 @@ async def create_from_pip(

:param package_name: Pip package name
:type package_name: str
:param pip_version: Pip version constraint, defaults to None
:type pip_version: Optional[str], optional
:param registry_url: Pip registry URL, defaults to None
:type registry_url: Optional[str], optional
:param agent_setup: Setup commands to run after installation, defaults to None
Expand All @@ -665,8 +657,6 @@ async def create_from_pip(
)

pip_config: Pip = {"package_name": package_name}
if pip_version is not None:
pip_config["pip_version"] = pip_version
if registry_url is not None:
pip_config["registry_url"] = registry_url
if agent_setup is not None:
Expand Down
20 changes: 7 additions & 13 deletions src/runloop_api_client/sdk/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ def create_from_npm(
self,
*,
package_name: str,
npm_version: Optional[str] = None,
registry_url: Optional[str] = None,
agent_setup: Optional[list[str]] = None,
**params: Unpack[SDKAgentCreateParams],
Expand All @@ -603,13 +602,11 @@ def create_from_npm(

Example:
>>> agent = runloop.agent.create_from_npm(
... name="my-npm-agent", package_name="@runloop/example-agent", npm_version="^1.0.0"
... name="my-npm-agent", package_name="@runloop/example-agent", version="1.0.0"
... )

:param package_name: NPM package name
:type package_name: str
:param npm_version: NPM version constraint, defaults to None
:type npm_version: Optional[str], optional
:param registry_url: NPM registry URL, defaults to None
:type registry_url: Optional[str], optional
:param agent_setup: Setup commands to run after installation, defaults to None
Expand All @@ -625,8 +622,6 @@ def create_from_npm(
)

npm_config: Npm = {"package_name": package_name}
if npm_version is not None:
npm_config["npm_version"] = npm_version
if registry_url is not None:
npm_config["registry_url"] = registry_url
if agent_setup is not None:
Expand All @@ -639,7 +634,6 @@ def create_from_pip(
self,
*,
package_name: str,
pip_version: Optional[str] = None,
registry_url: Optional[str] = None,
agent_setup: Optional[list[str]] = None,
**params: Unpack[SDKAgentCreateParams],
Expand All @@ -648,13 +642,11 @@ def create_from_pip(

Example:
>>> agent = runloop.agent.create_from_pip(
... name="my-pip-agent", package_name="runloop-example-agent", pip_version=">=1.0.0"
... name="my-pip-agent", package_name="runloop-example-agent", version="1.0.0"
... )

:param package_name: Pip package name
:type package_name: str
:param pip_version: Pip version constraint, defaults to None
:type pip_version: Optional[str], optional
:param registry_url: Pip registry URL, defaults to None
:type registry_url: Optional[str], optional
:param agent_setup: Setup commands to run after installation, defaults to None
Expand All @@ -670,8 +662,6 @@ def create_from_pip(
)

pip_config: Pip = {"package_name": package_name}
if pip_version is not None:
pip_config["pip_version"] = pip_version
if registry_url is not None:
pip_config["registry_url"] = registry_url
if agent_setup is not None:
Expand All @@ -696,6 +686,7 @@ def create_from_git(
... repository="https://github.com/user/agent-repo",
... ref="main",
... agent_setup=["npm install", "npm run build"],
... version="1.0.0",
... )

:param repository: Git repository URL
Expand Down Expand Up @@ -737,7 +728,10 @@ def create_from_object(
>>> obj = runloop.storage_object.upload_from_dir("./my-agent")
>>> # Then create agent from the object
>>> agent = runloop.agent.create_from_object(
... name="my-object-agent", object_id=obj.id, agent_setup=["chmod +x setup.sh", "./setup.sh"]
... name="my-object-agent",
... object_id=obj.id,
... agent_setup=["chmod +x setup.sh", "./setup.sh"],
... version="1.0.0",
... )

:param object_id: Storage object ID
Expand Down
22 changes: 18 additions & 4 deletions tests/sdk/test_async_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ async def test_create(self, mock_async_client: AsyncMock, agent_view: MockAgentV
client = AsyncAgentOps(mock_async_client)
agent = await client.create(
name="test-agent",
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand Down Expand Up @@ -901,6 +902,7 @@ async def test_create_from_npm(self, mock_async_client: AsyncMock, agent_view: M
agent = await client.create_from_npm(
name="test-agent",
package_name="@runloop/example-agent",
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -913,6 +915,7 @@ async def test_create_from_npm(self, mock_async_client: AsyncMock, agent_view: M
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -926,9 +929,9 @@ async def test_create_from_npm_with_all_options(
agent = await client.create_from_npm(
name="test-agent",
package_name="@runloop/example-agent",
npm_version="1.2.3",
registry_url="https://registry.example.com",
agent_setup=["npm install", "npm run setup"],
version="1.2.3",
extra_headers={"X-Custom": "header"},
)

Expand All @@ -939,12 +942,12 @@ async def test_create_from_npm_with_all_options(
"type": "npm",
"npm": {
"package_name": "@runloop/example-agent",
"npm_version": "1.2.3",
"registry_url": "https://registry.example.com",
"agent_setup": ["npm install", "npm run setup"],
},
},
name="test-agent",
version="1.2.3",
extra_headers={"X-Custom": "header"},
)

Expand All @@ -957,6 +960,7 @@ async def test_create_from_npm_raises_when_source_provided(self, mock_async_clie
await client.create_from_npm(
name="test-agent",
package_name="@runloop/example-agent",
version="1.2.3",
source={"type": "git", "git": {"repository": "https://github.com/example/repo"}},
)

Expand All @@ -969,6 +973,7 @@ async def test_create_from_pip(self, mock_async_client: AsyncMock, agent_view: M
agent = await client.create_from_pip(
name="test-agent",
package_name="runloop-example-agent",
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -981,6 +986,7 @@ async def test_create_from_pip(self, mock_async_client: AsyncMock, agent_view: M
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -994,9 +1000,9 @@ async def test_create_from_pip_with_all_options(
agent = await client.create_from_pip(
name="test-agent",
package_name="runloop-example-agent",
pip_version="1.2.3",
registry_url="https://pypi.example.com",
agent_setup=["pip install extra-deps"],
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -1006,12 +1012,12 @@ async def test_create_from_pip_with_all_options(
"type": "pip",
"pip": {
"package_name": "runloop-example-agent",
"pip_version": "1.2.3",
"registry_url": "https://pypi.example.com",
"agent_setup": ["pip install extra-deps"],
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -1023,6 +1029,7 @@ async def test_create_from_git(self, mock_async_client: AsyncMock, agent_view: M
agent = await client.create_from_git(
name="test-agent",
repository="https://github.com/example/agent-repo",
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -1035,6 +1042,7 @@ async def test_create_from_git(self, mock_async_client: AsyncMock, agent_view: M
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -1050,6 +1058,7 @@ async def test_create_from_git_with_all_options(
repository="https://github.com/example/agent-repo",
ref="develop",
agent_setup=["npm install", "npm run build"],
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -1064,6 +1073,7 @@ async def test_create_from_git_with_all_options(
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -1075,6 +1085,7 @@ async def test_create_from_object(self, mock_async_client: AsyncMock, agent_view
agent = await client.create_from_object(
name="test-agent",
object_id="obj_123",
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -1087,6 +1098,7 @@ async def test_create_from_object(self, mock_async_client: AsyncMock, agent_view
},
},
name="test-agent",
version="1.2.3",
)

@pytest.mark.asyncio
Expand All @@ -1101,6 +1113,7 @@ async def test_create_from_object_with_agent_setup(
name="test-agent",
object_id="obj_123",
agent_setup=["chmod +x setup.sh", "./setup.sh"],
version="1.2.3",
)

assert isinstance(agent, AsyncAgent)
Expand All @@ -1114,6 +1127,7 @@ async def test_create_from_object_with_agent_setup(
},
},
name="test-agent",
version="1.2.3",
)


Expand Down
Loading
Loading