Skip to content

Commit

Permalink
Merge branch 'dev' into feat/stateless-service
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-agenta committed Dec 17, 2024
2 parents 19ff448 + 4334030 commit c1f386e
Show file tree
Hide file tree
Showing 41 changed files with 2,124 additions and 236 deletions.
11 changes: 8 additions & 3 deletions agenta-backend/agenta_backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest
import asyncio

from agenta_backend.tests.engine import test_db_engine as db_engine
from agenta_backend.utils.common import isOss

if isOss():
from agenta_backend.tests.engine import test_db_engine as db_engine


@pytest.fixture(scope="session", autouse=True)
Expand All @@ -17,6 +20,8 @@ def event_loop():

yield res

res.run_until_complete(db_engine.remove_db()) # drop database
res.run_until_complete(db_engine.close_db()) # close connections to database
if isOss():
res.run_until_complete(db_engine.remove_db()) # drop database
res.run_until_complete(db_engine.close_db()) # close connections to database

res._close() # close event loop # type: ignore
35 changes: 32 additions & 3 deletions agenta-cli/agenta/client/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
AgentaTreesResponse,
AggregatedResult,
AggregatedResultEvaluatorConfig,
AnalyticsResponse,
App,
AppVariantResponse,
AppVariantRevision,
BaseOutput,
BodyImportTestset,
BucketDto,
CollectStatusResponse,
ConfigDb,
ConfigDto,
Expand Down Expand Up @@ -42,6 +44,7 @@
EvaluatorOutputInterface,
ExceptionDto,
GetConfigResponse,
HeaderDto,
HttpValidationError,
HumanEvaluation,
HumanEvaluationScenario,
Expand All @@ -51,12 +54,14 @@
HumanEvaluationUpdate,
Image,
InviteRequest,
LegacyAnalyticsResponse,
LegacyDataPoint,
LifecycleDto,
LinkDto,
ListApiKeysResponse,
LlmRunRateLimit,
LlmTokens,
LmProvidersEnum,
MetricsDto,
NewHumanEvaluation,
NewTestset,
NodeDto,
Expand All @@ -74,11 +79,17 @@
Outputs,
ParentDto,
Permission,
ProjectsResponse,
ProviderKeyDto,
ProviderKind,
ReferenceDto,
ReferenceRequestModel,
Result,
RootDto,
Score,
SecretDto,
SecretKind,
SecretResponseDto,
SimpleEvaluationOutput,
Span,
SpanDetail,
Expand Down Expand Up @@ -111,6 +122,7 @@
)
from .errors import UnprocessableEntityError
from . import (
access_control,
apps,
bases,
configs,
Expand All @@ -120,12 +132,14 @@
evaluators,
observability,
observability_v_1,
scopes,
testsets,
variants,
vault,
)
from .client import AgentaApi, AsyncAgentaApi
from .containers import ContainerTemplatesResponse
from .observability_v_1 import Format, QueryTracesResponse
from .observability_v_1 import Format, QueryAnalyticsResponse, QueryTracesResponse
from .variants import AddVariantFromBaseAndConfigResponse

__all__ = [
Expand All @@ -140,12 +154,14 @@
"AgentaTreesResponse",
"AggregatedResult",
"AggregatedResultEvaluatorConfig",
"AnalyticsResponse",
"App",
"AppVariantResponse",
"AppVariantRevision",
"AsyncAgentaApi",
"BaseOutput",
"BodyImportTestset",
"BucketDto",
"CollectStatusResponse",
"ConfigDb",
"ConfigDto",
Expand Down Expand Up @@ -175,6 +191,7 @@
"ExceptionDto",
"Format",
"GetConfigResponse",
"HeaderDto",
"HttpValidationError",
"HumanEvaluation",
"HumanEvaluationScenario",
Expand All @@ -184,12 +201,14 @@
"HumanEvaluationUpdate",
"Image",
"InviteRequest",
"LegacyAnalyticsResponse",
"LegacyDataPoint",
"LifecycleDto",
"LinkDto",
"ListApiKeysResponse",
"LlmRunRateLimit",
"LlmTokens",
"LmProvidersEnum",
"MetricsDto",
"NewHumanEvaluation",
"NewTestset",
"NodeDto",
Expand All @@ -207,12 +226,19 @@
"Outputs",
"ParentDto",
"Permission",
"ProjectsResponse",
"ProviderKeyDto",
"ProviderKind",
"QueryAnalyticsResponse",
"QueryTracesResponse",
"ReferenceDto",
"ReferenceRequestModel",
"Result",
"RootDto",
"Score",
"SecretDto",
"SecretKind",
"SecretResponseDto",
"SimpleEvaluationOutput",
"Span",
"SpanDetail",
Expand Down Expand Up @@ -243,6 +269,7 @@
"WorkspaceResponse",
"WorkspaceRole",
"WorkspaceRoleResponse",
"access_control",
"apps",
"bases",
"configs",
Expand All @@ -252,6 +279,8 @@
"evaluators",
"observability",
"observability_v_1",
"scopes",
"testsets",
"variants",
"vault",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file was auto-generated by Fern from our API Definition.
167 changes: 167 additions & 0 deletions agenta-cli/agenta/client/backend/access_control/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# This file was auto-generated by Fern from our API Definition.

from ..core.client_wrapper import SyncClientWrapper
import typing
from ..core.request_options import RequestOptions
from ..core.pydantic_utilities import parse_obj_as
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.http_validation_error import HttpValidationError
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper


class AccessControlClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper

def verify_permissions(
self,
*,
action: typing.Optional[str] = None,
resource_type: typing.Optional[str] = None,
resource_id: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.Optional[typing.Any]:
"""
Parameters
----------
action : typing.Optional[str]
resource_type : typing.Optional[str]
resource_id : typing.Optional[str]
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
from agenta import AgentaApi
client = AgentaApi(
api_key="YOUR_API_KEY",
base_url="https://yourhost.com/path/to/api",
)
client.access_control.verify_permissions()
"""
_response = self._client_wrapper.httpx_client.request(
"permissions/verify",
method="GET",
params={
"action": action,
"resource_type": resource_type,
"resource_id": resource_id,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
typing.Optional[typing.Any],
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
typing.cast(
HttpValidationError,
parse_obj_as(
type_=HttpValidationError, # type: ignore
object_=_response.json(),
),
)
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncAccessControlClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper

async def verify_permissions(
self,
*,
action: typing.Optional[str] = None,
resource_type: typing.Optional[str] = None,
resource_id: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.Optional[typing.Any]:
"""
Parameters
----------
action : typing.Optional[str]
resource_type : typing.Optional[str]
resource_id : typing.Optional[str]
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Optional[typing.Any]
Successful Response
Examples
--------
import asyncio
from agenta import AsyncAgentaApi
client = AsyncAgentaApi(
api_key="YOUR_API_KEY",
base_url="https://yourhost.com/path/to/api",
)
async def main() -> None:
await client.access_control.verify_permissions()
asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
"permissions/verify",
method="GET",
params={
"action": action,
"resource_type": resource_type,
"resource_id": resource_id,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
typing.Optional[typing.Any],
parse_obj_as(
type_=typing.Optional[typing.Any], # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
typing.cast(
HttpValidationError,
parse_obj_as(
type_=HttpValidationError, # type: ignore
object_=_response.json(),
),
)
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
Loading

0 comments on commit c1f386e

Please sign in to comment.