Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
18 changes: 18 additions & 0 deletions flaskapi/flask_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def _deployment_mode() -> str:
def _get_all_items(api_call: Callable, *args, **kwargs):
"""Helper function to get all items from a paginated API call."""
list_len = api_call(limit=1,*args, **kwargs).total
if "limit" not in kwargs:
kwargs["limit"] = int(np.min([50, list_len])) ## max allowed is 50
Copy link

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NumPy's np.min for comparing two scalar values adds an external dependency; consider using the built-in min(50, list_len) for simplicity and reduced overhead.

Copilot uses AI. Check for mistakes.

retrieved = 0
items = []
page = 1
Expand Down Expand Up @@ -360,6 +363,21 @@ def _timeit(fun: Callable, N: int, *args, **kwargs):

# test_job_retrieval_endpoints_speed(job_uid="aa5453be-d9e5-4e8a-a7a5-29acd113f1d2", N=30)


def test_job_retrieval_paginated(function_uid: str):
def _timeit(fun: Callable, *args, **kwargs):
import time
start_time = time.time()
result = fun(*args, **kwargs)
end_time = time.time()
_logger.info(f"Retrieved {len(result)} items in {end_time - start_time:.4f} seconds")
_logger.info(f"First item: {result[0] if result else 'No items retrieved'}")
_logger.info(f"Last item: {result[-1] if result else 'No items retrieved'}")
_logger.info(f"That is {(end_time - start_time)/len(result):.2f} seconds per item")
Comment on lines +368 to +376
Copy link

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested _timeit duplicates the existing top-level helper; reuse the original function to avoid code duplication and ensure consistency.

Suggested change
def _timeit(fun: Callable, *args, **kwargs):
import time
start_time = time.time()
result = fun(*args, **kwargs)
end_time = time.time()
_logger.info(f"Retrieved {len(result)} items in {end_time - start_time:.4f} seconds")
_logger.info(f"First item: {result[0] if result else 'No items retrieved'}")
_logger.info(f"Last item: {result[-1] if result else 'No items retrieved'}")
_logger.info(f"That is {(end_time - start_time)/len(result):.2f} seconds per item")
def log_callback(result, *args, **kwargs):
_logger.info(f"Retrieved {len(result)} items in {kwargs['execution_time']:.4f} seconds")
_logger.info(f"First item: {result[0] if result else 'No items retrieved'}")
_logger.info(f"Last item: {result[-1] if result else 'No items retrieved'}")
_logger.info(f"That is {kwargs['execution_time']/len(result):.2f} seconds per item")
_timeit(_get_all_items, api_call=functions_api_instance.list_function_jobs_for_functionid, function_id=function_uid, log_callback=log_callback) # type: ignore

Copilot uses AI. Check for mistakes.
_timeit(_get_all_items, api_call=functions_api_instance.list_function_jobs_for_functionid, function_id=function_uid) # type: ignore

# test_job_retrieval_paginated(function_uid="eea21c0d-6c2b-4cf4-91d1-116e6550cb22")

def _create_training_file_from_jobs(jobs: List[FunctionJob], input_vars: List[str], output_response: str, folder_name: str = "evaluate") -> Path:
output_response_sanitized = sanitize_varnames(output_response)
completed_jobs = [job for job in jobs if job["status"].lower() == "completed" or job["status"].lower() == "success"] # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions node/src/components/JobRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const JobRow = (props: JobRowProps) => {
? Object.entries(job.job.outputs).map(([key, value], idx) => {
return (
<Box key={idx} display={"inline"}>
{key} : {(value as number).toExponential(3)}{", "}
{key} : {(value as number).toPrecision(3)}{", "}
</Box>
);
})
Expand All @@ -61,7 +61,7 @@ const JobRow = (props: JobRowProps) => {
const inputs = Object.entries(job.job.inputs).map(([key, value], idx) => {
return (
<Box key={idx} display={"inline"}>
{key} : {(value as number).toExponential(3)}{", "}
{key} : {(value as number).toPrecision(3)}{", "}
</Box>
);
})
Expand Down
2 changes: 1 addition & 1 deletion node/src/components/Metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Metric = (props: MetricPropsType) => {
fontWeight={100}
color={color}
>
{metricName}: <strong>{metricValue.toFixed(4)}</strong>
{metricName}: <strong>{metricValue.toPrecision(3)}</strong>
</Typography>)
}

Expand Down
1 change: 0 additions & 1 deletion node/src/components/navigation/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const types: { [key in HeaderTypes]: TypographyVariant } = {
function Header(props: HeaderProps) {
const { tabTitle, infoText, ExtendedInfoText, headerType, helpContents } =
props;
console.log("tabTitle: ", tabTitle, "infoText", infoText)
return (
<HeaderContainer headerType={headerType}>
<Box flex={1} display="flex" alignItems="center">
Expand Down