Skip to content

Commit 9eaa4be

Browse files
authored
Merge pull request #2853 from Agenta-AI/release/v0.59.7
release/v0.59.7
2 parents 8f499f2 + 3829d21 commit 9eaa4be

File tree

10 files changed

+86
-49
lines changed

10 files changed

+86
-49
lines changed

api/oss/src/services/db_manager.py

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,8 +2608,18 @@ async def remove_testsets(testset_ids: List[str]):
26082608
query = select(TestSetDB).where(TestSetDB.id.in_(testset_ids))
26092609
result = await session.execute(query)
26102610
testsets = result.scalars().all()
2611-
for testset in testsets:
2611+
2612+
for i, testset in enumerate(testsets):
2613+
log.info(
2614+
f"[TESTSET] DELETE ({i}):",
2615+
project_id=testset.project_id,
2616+
testset_id=testset.id,
2617+
count=len(testset.csvdata),
2618+
size=len(dumps(testset.csvdata).encode("utf-8")),
2619+
)
2620+
26122621
await session.delete(testset)
2622+
26132623
await session.commit()
26142624

26152625

@@ -2772,8 +2782,18 @@ async def fetch_testset_by_id(testset_id: str) -> Optional[TestSetDB]:
27722782
async with engine.core_session() as session:
27732783
result = await session.execute(select(TestSetDB).filter_by(id=testset_uuid))
27742784
testset = result.scalars().first()
2785+
27752786
if not testset:
27762787
raise NoResultFound(f"Testset with id {testset_id} not found")
2788+
2789+
log.info(
2790+
"[TESTSET] READ:",
2791+
project_id=testset.project_id,
2792+
testset_id=testset.id,
2793+
count=len(testset.csvdata),
2794+
size=len(dumps(testset.csvdata).encode("utf-8")),
2795+
)
2796+
27772797
return testset
27782798

27792799

@@ -2791,21 +2811,21 @@ async def create_testset(project_id: str, testset_data: Dict[str, Any]):
27912811
"""
27922812

27932813
async with engine.core_session() as session:
2794-
testset_db = TestSetDB(**testset_data, project_id=uuid.UUID(project_id))
2814+
testset = TestSetDB(**testset_data, project_id=uuid.UUID(project_id))
27952815

27962816
log.info(
2797-
"Saving testset:",
2798-
project_id=testset_db.project_id,
2799-
testset_id=testset_db.id,
2800-
count=len(testset_db.csvdata),
2801-
size=len(dumps(testset_db.csvdata).encode("utf-8")),
2817+
"[TESTSET] CREATE:",
2818+
project_id=testset.project_id,
2819+
testset_id=testset.id,
2820+
count=len(testset.csvdata),
2821+
size=len(dumps(testset.csvdata).encode("utf-8")),
28022822
)
28032823

2804-
session.add(testset_db)
2824+
session.add(testset)
28052825
await session.commit()
2806-
await session.refresh(testset_db)
2826+
await session.refresh(testset)
28072827

2808-
return testset_db
2828+
return testset
28092829

28102830

28112831
async def update_testset(testset_id: str, values_to_update: dict) -> None:
@@ -2824,11 +2844,12 @@ async def update_testset(testset_id: str, values_to_update: dict) -> None:
28242844

28252845
# Validate keys in values_to_update and update attributes
28262846
valid_keys = [key for key in values_to_update.keys() if hasattr(testset, key)]
2847+
28272848
for key in valid_keys:
28282849
setattr(testset, key, values_to_update[key])
28292850

28302851
log.info(
2831-
"Saving testset:",
2852+
"[TESTSET] UPDATE:",
28322853
project_id=testset.project_id,
28332854
testset_id=testset.id,
28342855
count=len(testset.csvdata),
@@ -2854,6 +2875,16 @@ async def fetch_testsets_by_project_id(project_id: str):
28542875
select(TestSetDB).filter_by(project_id=uuid.UUID(project_id))
28552876
)
28562877
testsets = result.scalars().all()
2878+
2879+
for i, testset in enumerate(testsets):
2880+
log.info(
2881+
f"[TESTSET] READ ({i}):",
2882+
project_id=testset.project_id,
2883+
testset_id=testset.id,
2884+
count=len(testset.csvdata),
2885+
size=len(dumps(testset.csvdata).encode("utf-8")),
2886+
)
2887+
28572888
return testsets
28582889

28592890

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "api"
3-
version = "0.59.6"
3+
version = "0.59.7"
44
description = "Agenta API"
55
authors = [
66
{ name = "Mahmoud Mabrouk", email = "mahmoud@agenta.ai" },

docs/docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const config: Config = {
2323
titleDelimiter: "-",
2424
// Even if you don't use internationalization, you can use this field to set
2525
// useful metadata like html lang. For example, if your site is Chinese, you
26-
// may want to replace "en" with "zh-Hans".
26+
// may want to replace "en" with "zh-Hans".
2727
i18n: {
2828
defaultLocale: "en",
2929
locales: ["en"],

sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "agenta"
3-
version = "0.59.6"
3+
version = "0.59.7"
44
description = "The SDK for agenta is an open-source LLMOps platform."
55
readme = "README.md"
66
authors = [

web/ee/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@agenta/ee",
3-
"version": "0.59.6",
3+
"version": "0.59.7",
44
"private": true,
55
"engines": {
66
"node": ">=18"

web/oss/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@agenta/oss",
3-
"version": "0.59.6",
3+
"version": "0.59.7",
44
"private": true,
55
"engines": {
66
"node": ">=18"

web/oss/src/state/testset/atoms/fetcher.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {fetchTestsets, fetchPreviewTestsets} from "@/oss/services/testsets/api"
66
import {PreviewTestsetsQueryPayload} from "@/oss/services/testsets/api/types"
77

88
import {projectIdAtom} from "../../project"
9+
import {userAtom} from "../../profile"
910

1011
// Local options type for enabling/disabling queries
1112
interface TestsetsQueryOptions {
@@ -17,17 +18,19 @@ interface TestsetsQueryOptions {
1718
*/
1819
export const testsetsQueryAtom = atomWithQuery<testset[]>((get) => {
1920
const projectId = get(projectIdAtom)
21+
const user = get(userAtom)
2022

2123
return {
2224
queryKey: ["testsets", projectId],
2325
queryFn: () => {
2426
return fetchTestsets()
2527
},
26-
staleTime: 1000 * 60,
28+
staleTime: 5 * 60 * 1000,
29+
gcTime: 30 * 60 * 1000,
2730
refetchOnWindowFocus: false,
2831
refetchOnReconnect: false,
2932
refetchOnMount: false,
30-
enabled: !!projectId,
33+
enabled: !!user?.id && !!projectId,
3134
}
3235
})
3336

@@ -41,6 +44,7 @@ export const previewTestsetsQueryAtomFamily = atomFamily(
4144
}: {payload?: PreviewTestsetsQueryPayload; enabled?: boolean} = {}) =>
4245
atomWithQuery<testset[]>((get) => {
4346
const projectId = get(projectIdAtom)
47+
const user = get(userAtom)
4448

4549
const payloadKey = JSON.stringify(payload || {})
4650

@@ -51,25 +55,35 @@ export const previewTestsetsQueryAtomFamily = atomFamily(
5155
refetchOnWindowFocus: false,
5256
refetchOnReconnect: false,
5357
refetchOnMount: false,
54-
enabled: enabled && !!projectId,
58+
enabled: !!user?.id && enabled && !!projectId,
5559
}
5660
}),
61+
(a, b) => {
62+
const aEnabled = a?.enabled ?? true
63+
const bEnabled = b?.enabled ?? true
64+
const aKey = JSON.stringify(a?.payload ?? {})
65+
const bKey = JSON.stringify(b?.payload ?? {})
66+
return aEnabled === bEnabled && aKey === bKey
67+
},
5768
)
5869

59-
export const testsetsQueryAtomFamily = atomFamily(({enabled = true}: TestsetsQueryOptions = {}) =>
60-
atomWithQuery<testset[]>((get) => {
61-
const projectId = get(projectIdAtom)
70+
export const testsetsQueryAtomFamily = atomFamily(
71+
({enabled = true}: TestsetsQueryOptions = {}) =>
72+
atomWithQuery<testset[]>((get) => {
73+
const projectId = get(projectIdAtom)
74+
const user = get(userAtom)
6275

63-
return {
64-
queryKey: ["testsets", projectId],
65-
queryFn: fetchTestsets,
66-
staleTime: 1000 * 60,
67-
refetchOnWindowFocus: false,
68-
refetchOnReconnect: false,
69-
refetchOnMount: false,
70-
enabled: enabled && !!projectId,
71-
}
72-
}),
76+
return {
77+
queryKey: ["testsets", projectId],
78+
queryFn: fetchTestsets,
79+
staleTime: 1000 * 60,
80+
refetchOnWindowFocus: false,
81+
refetchOnReconnect: false,
82+
refetchOnMount: false,
83+
enabled: !!user?.id && enabled && !!projectId,
84+
}
85+
}),
86+
(a, b) => (a?.enabled ?? true) === (b?.enabled ?? true),
7387
)
7488

7589
/**

web/oss/src/state/testset/hooks/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import {useMemo} from "react"
2-
31
import {useAtom} from "jotai"
42

53
import {PreviewTestsetsQueryPayload} from "@/oss/services/testsets/api/types"
64

75
import {
86
previewTestsetsQueryAtom,
97
previewTestsetsQueryAtomFamily,
10-
testsetsQueryAtomFamily,
8+
testsetsQueryAtom,
119
} from "../atoms/fetcher"
1210

1311
export {useTestset, testsetQueryAtomFamily} from "./useTestset"
@@ -19,8 +17,7 @@ export {useTestset, testsetQueryAtomFamily} from "./useTestset"
1917
* @returns Object with `testsets`, `isError`, `error`, `isLoading`, `mutate`
2018
*/
2119
export const useTestsetsData = ({enabled = true} = {}) => {
22-
const stableAtom = useMemo(() => testsetsQueryAtomFamily({enabled}), [enabled])
23-
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(stableAtom)
20+
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(testsetsQueryAtom)
2421

2522
return {
2623
testsets: testsets ?? [],
@@ -61,11 +58,9 @@ export const usePreviewTestsetsDataWithFilters = (
6158
payload: PreviewTestsetsQueryPayload = {},
6259
{enabled = true}: {enabled?: boolean} = {},
6360
) => {
64-
const stableAtom = useMemo(
65-
() => previewTestsetsQueryAtomFamily({payload, enabled}),
66-
[payload, enabled],
61+
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(
62+
previewTestsetsQueryAtomFamily({payload, enabled}),
6763
)
68-
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(stableAtom)
6964

7065
return {
7166
testsets: testsets ?? [],

web/oss/src/state/testset/index.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import axios from "@/oss/lib/api/assets/axiosConfig"
77
import {getAgentaApiUrl} from "@/oss/lib/helpers/api"
88
import {TestSet} from "@/oss/lib/Types"
99

10-
import {previewTestsetsQueryAtom, testsetsQueryAtomFamily} from "./atoms/fetcher"
10+
import {previewTestsetsQueryAtom, testsetsQueryAtom} from "./atoms/fetcher"
1111
import {useTestset} from "./hooks/useTestset"
1212

1313
/**
1414
* Hook for regular/legacy testsets
1515
*/
1616
export const useTestsetsData = ({enabled = true} = {}) => {
17-
const stableAtom = useMemo(() => testsetsQueryAtomFamily({enabled}), [enabled])
18-
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(stableAtom)
17+
const [{data: testsets, isPending, refetch, error, isError}] = useAtom(testsetsQueryAtom)
1918
const queryClient = useQueryClient()
2019
const [columnsFallback, setColumnsFallback] = useState<Record<string, string[]>>({})
2120
const [csvVersion, setCsvVersion] = useState(0)
@@ -114,20 +113,18 @@ export const useTestsetsData = ({enabled = true} = {}) => {
114113
return () => controller.abort()
115114
}, [testsets, columnsByTestsetId, columnsFallback])
116115

117-
// When any testsetCsvData query updates, bump csvVersion and optionally refetch testsets
116+
// When any testsetCsvData query updates, bump csvVersion
118117
useEffect(() => {
119118
const unsubscribe = queryClient.getQueryCache().subscribe((event) => {
120119
// Only react to updates of our csv data queries
121120
const q = (event as any)?.query
122121
const key0 = q?.queryKey?.[0]
123122
if (key0 === "testsetCsvData") {
124123
setCsvVersion((v) => v + 1)
125-
// Optionally refetch to propagate other derived server info
126-
refetch()
127124
}
128125
})
129126
return unsubscribe
130-
}, [queryClient, refetch])
127+
}, [queryClient])
131128

132129
return {
133130
testsets: testsets ?? [],

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agenta-web",
3-
"version": "0.59.6",
3+
"version": "0.59.7",
44
"workspaces": [
55
"ee",
66
"oss",

0 commit comments

Comments
 (0)