From 7faa4d0ef33ba7c0baa5b97ffa364e93c1e15521 Mon Sep 17 00:00:00 2001 From: gtarpenning Date: Tue, 14 Jan 2025 14:49:39 -0800 Subject: [PATCH] chore(ui): update export code to use get_calls --- .../pages/CallsPage/CallsTableButtons.tsx | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsTableButtons.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsTableButtons.tsx index e6956fb3d4a8..34bea9cc89e6 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsTableButtons.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/CallsTableButtons.tsx @@ -529,28 +529,24 @@ function makeCodeText( sortBy: Array<{field: string; direction: 'asc' | 'desc'}>, includeFeedback: boolean ) { - let codeStr = `import weave\nassert weave.__version__ >= "0.50.14", "Please upgrade weave!" \n\nclient = weave.init("${entity}/${project}")`; - codeStr += `\ncalls = client.server.calls_query_stream({\n`; - codeStr += ` "project_id": "${entity}/${project}",\n`; - + let codeStr = `import weave\nassert weave.__version__ >= "0.51.29", "Please upgrade weave!"\n\napi = weave.init("${project}")`; + codeStr += `\ncalls = api.get_calls(\n`; const filteredCallIds = callIds ?? filter.callIds; if (filteredCallIds && filteredCallIds.length > 0) { - codeStr += ` "filter": {"call_ids": ["${filteredCallIds.join( - '", "' - )}"]},\n`; + codeStr += ` filter={"call_ids": ["${filteredCallIds.join('", "')}"]},\n`; if (expandColumns.length > 0) { const expandColumnsStr = JSON.stringify(expandColumns, null, 0); - codeStr += ` "expand_columns": ${expandColumnsStr},\n`; + codeStr += ` expand_columns=${expandColumnsStr},\n`; } if (includeFeedback) { - codeStr += ` "include_feedback": true,\n`; + codeStr += ` include_feedback=True,\n`; } // specifying call_ids ignores other filters, return early codeStr += `})`; return codeStr; } if (Object.values(filter).some(value => value !== undefined)) { - codeStr += ` "filter": {`; + codeStr += ` filter={`; if (filter.opVersionRefs) { codeStr += `"op_names": ["${filter.opVersionRefs.join('", "')}"],`; } @@ -573,21 +569,21 @@ function makeCodeText( codeStr += `},\n`; } if (query) { - codeStr += ` "query": ${JSON.stringify(query, null, 0)},\n`; + codeStr += ` query=${JSON.stringify(query, null, 0)},\n`; } if (expandColumns.length > 0) { const expandColumnsStr = JSON.stringify(expandColumns, null, 0); - codeStr += ` "expand_columns": ${expandColumnsStr},\n`; + codeStr += ` expand_columns=${expandColumnsStr},\n`; } if (sortBy.length > 0) { - codeStr += ` "sort_by": ${JSON.stringify(sortBy, null, 0)},\n`; + codeStr += ` sort_by=${JSON.stringify(sortBy, null, 0)},\n`; } if (includeFeedback) { - codeStr += ` "include_feedback": True,\n`; + codeStr += ` include_feedback=True,\n`; } - codeStr += `})`; + codeStr += `)`; return codeStr; }