Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflow inputs for model comparison #13

Merged
merged 2 commits into from
Nov 11, 2024
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
12 changes: 11 additions & 1 deletion src/ui/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@ def run_compare(eval_dirs: List[str] = None):
f.validate_paths(g.eval_dirs)

# ==================== Workflow input ====================
w.workflow_input(g.api, team_files_dirs=g.eval_dirs)
reports = None
try:
reports_paths = [path.rstrip("/") + "/visualizations/template.vue" for path in g.eval_dirs]
reports = [g.api.file.get_info_by_path(g.team_id, path) for path in reports_paths]
except Exception as e:
sly.logger.warning(f"Failed to get model benchmark reports FileInfos: {repr(e)}")

if reports is not None:
w.workflow_input(g.api, model_benchmark_reports=reports)
else:
w.workflow_input(g.api, team_files_dirs=g.eval_dirs)
# =======================================================

comp = ModelComparison(g.api, g.eval_dirs, progress=comp_pbar, workdir=workdir)
Expand Down
10 changes: 10 additions & 0 deletions src/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def workflow_input(
project_info: Optional[sly.ProjectInfo] = None,
session_id: Optional[int] = None,
team_files_dirs: Optional[List[str]] = None,
model_benchmark_reports: Optional[List[sly.api.file_api.FileInfo]] = None,
):
if project_info:
# Create a project version before the task starts
Expand Down Expand Up @@ -52,6 +53,15 @@ def workflow_input(
except Exception as e:
sly.logger.debug(f"Failed to add input to the workflow: {repr(e)}")

if model_benchmark_reports:
# Add input model benchmark reports to the workflow
try:
for model_benchmark_report in model_benchmark_reports:
api.app.workflow.add_input_file(model_benchmark_report)
sly.logger.debug(f"Workflow Input: Model Benchmark Report ID - {model_benchmark_report.id}")
except Exception as e:
sly.logger.debug(f"Failed to add input to the workflow: {repr(e)}")


def workflow_output(
api: sly.Api,
Expand Down
Loading