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

Add modal and autostart from script #4

Merged
merged 2 commits into from
Aug 28, 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
15 changes: 14 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@
"entrypoint": "python -m uvicorn src.main:app --host 0.0.0.0 --port 8000",
"port": 8000,
"docker_image": "supervisely/model-benchmark:0.0.1",
"instance_version": "6.11.10"
"instance_version": "6.11.10",
"context_menu": {
"target": ["images_project"]
},
"modal_template": "src/modal.html",
"modal_template_state": {
"sessionId": null,
"autoStart": false,
"sessionOptions": {
"sessionTags": ["deployed_nn"],
"showLabel": false,
"size": "small"
}
}
}
8 changes: 7 additions & 1 deletion src/globals.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
from distutils.util import strtobool

import supervisely as sly
from dotenv import load_dotenv

import supervisely as sly

if sly.is_development():
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
Expand All @@ -21,3 +23,7 @@
project_id = sly.env.project_id(raise_not_found=False)
team_id = sly.env.team_id()
task_id = sly.env.task_id(raise_not_found=False)
session_id = os.environ.get("modal.state.sessionId", None)
if session_id is not None:
session_id = int(session_id)
autostart = bool(strtobool(os.environ.get("modal.state.autoStart", "false")))
17 changes: 12 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Optional

import src.globals as g
import src.workflow as w
import supervisely as sly
import supervisely.app.widgets as widgets
from supervisely.nn.benchmark import ObjectDetectionBenchmark

import src.globals as g
import src.workflow as w


def main_func():
api = g.api
Expand All @@ -17,7 +16,6 @@ def main_func():
w.workflow_input(api, project, session_id)
# =======================================================


pbar.show()
report_model_benchmark.hide()

Expand Down Expand Up @@ -105,9 +103,18 @@ def handle(session_id: Optional[int]):


@button.click
def handle():
def start_evaluation():
creating_report_f.show()
main_func()


app = sly.Application(layout=layout, static_dir=g.STATIC_DIR)

if g.project_id:
sel_project.set_project_id(g.project_id)

if g.session_id:
sel_app_session.set_session_id(g.session_id)

if g.autostart:
start_evaluation()
17 changes: 17 additions & 0 deletions src/modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div id="embeddings-calculator">
<sly-field title="Select Served session" description="select ">
<sly-select-app-session
:group-id="context.teamId"
:app-session-id.sync="state.sessionId"
:options="state.sessionOptions"
>
</sly-select-app-session>
</sly-field>
<sly-field
v-if="state.sessionId"
title="Auto start"
description="Specify if the evaluation should start automatically after the app starts"
>
<el-checkbox v-model="state.autoStart">Enable</el-checkbox>
</sly-field>
</div>