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

Experimental functions for resuming a task run #910

Merged
merged 7 commits into from
Jul 2, 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
4 changes: 2 additions & 2 deletions docs/web/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const config = {
type: "doc",
docId: "reference/overview",
position: "left",
label: "API Reference",
label: "Reference",
},
{ to: "/blog", label: "Blog", position: "left" },
{
Expand All @@ -115,7 +115,7 @@ const config = {
to: "/docs/explanations/architecture_overview",
},
{
label: "API Reference",
label: "Reference",
to: "/docs/reference/overview",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def generate_data_json_config():
form_config_path=form_config_path,
token_sets_values_config_path=token_sets_values_config_path,
task_data_config_path=task_data_config_path,
data_path=data_path,
)

# Set env var for `custom_validators.js`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def generate_data_json_config():
form_config_path=form_config_path,
token_sets_values_config_path=token_sets_values_config_path,
task_data_config_path=task_data_config_path,
data_path=data_path,
)

# Set env var for `custom_validators.js`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def generate_data_json_config():
form_config_path=form_config_path,
token_sets_values_config_path=token_sets_values_config_path,
task_data_config_path=task_data_config_path,
data_path=data_path,
)


Expand Down
2 changes: 0 additions & 2 deletions mephisto/abstractions/providers/mock/mock_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def ensure_requester_exists(self, requester_id: str) -> None:
table_name="requesters",
params={
"requester_id": requester_id,
"is_registered": False,
},
select_field="requester_id",
)
Expand Down Expand Up @@ -194,7 +193,6 @@ def ensure_unit_exists(self, unit_id: str) -> None:
table_name="units",
params={
"unit_id": unit_id,
"is_expired": False,
},
select_field="unit_id",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ def ensure_worker_exists(self, worker_id: str) -> None:
table_name="workers",
params={
"worker_id": worker_id,
"is_blocked": False,
},
select_field="id",
)
Expand Down Expand Up @@ -392,7 +391,6 @@ def ensure_unit_exists(self, unit_id: str) -> None:
table_name="units",
params={
"unit_id": unit_id,
"is_expired": False,
},
select_field="id",
)
Expand Down
6 changes: 2 additions & 4 deletions mephisto/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def metrics_cli(args):
def review_app(
info: ScriptInfo,
host: Optional[str],
port: Optional[str],
port: Optional[int],
debug: bool = False,
force_rebuild: bool = False,
skip_build: bool = False,
Expand All @@ -384,7 +384,6 @@ def review_app(
"""
from flask.cli import show_server_banner
from flask.helpers import get_debug_flag
from flask.helpers import get_env
from mephisto.review_app.server import create_app
from werkzeug.serving import run_simple

Expand Down Expand Up @@ -435,8 +434,7 @@ def review_app(
debugger = debug

# Show Flask banner
eager_loading = not reload
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
show_server_banner(debug, info.app_import_path)

# Init Flask App
app = create_app(debug=debug)
Expand Down
37 changes: 30 additions & 7 deletions mephisto/data_model/task_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ class TaskRunArgs:
default="",
metadata={
"help": (
"The name of a shell script in your webapp directory that will run right after npm install and before npm build."
"This can be useful for local package development where you would want to link a package after installing dependencies from package.json"
"The name of a shell script in your webapp directory "
"that will run right after npm install and before npm build. "
"This can be useful for local package development where you would want "
"to link a package after installing dependencies from package.json"
)
},
)
Expand All @@ -142,13 +144,20 @@ class TaskRunArgs:
default=False,
metadata={
"help": (
"Determines if npm build should be ran every time the task is ran."
"By default there is an optimization that only builds the webapp when there is a change in its contents."
"It would make sense to set this to true when doing local package development as you want to force a rebuild after running the post_install_script."
"Determines if npm build should be ran every time the task is ran. "
"By default there is an optimization that only builds the webapp "
"when there is a change in its contents. "
"It would make sense to set this to true when doing local package development "
"as you want to force a rebuild after running the post_install_script."
)
},
)

resume_incomplete_run: Optional[bool] = field(
default=False,
metadata={"help": "Resume incomplete or interrupted TaskRun if it exists (EXPERIMENTAL)."},
)

@classmethod
def get_mock_params(cls) -> str:
"""Returns a param string with default / mock arguments to use for testing"""
Expand Down Expand Up @@ -425,10 +434,24 @@ def sync_completion_status(self) -> None:
self.db.update_task_run(self.db_id, is_completed=True)
self.__is_completed = True

def get_run_dir(self) -> str:
def resurrect_if_has_incomplete_assignments(self) -> None:
"""
Return the directory where the data from this run is stored
If TaskRun is already marked as completed, and we use `resume_incomplete_run` parameter
to resume this TaskRun, it must become incomplete in DB again
"""
assignments = self.get_has_assignments()
if self.__is_completed and assignments:
statuses = self.get_assignment_statuses()
has_incomplete = False
for status in AssignmentState.incomplete():
if statuses[status] > 0:
has_incomplete = True
if has_incomplete:
self.db.update_task_run(self.db_id, is_completed=False)
self.__is_completed = False

def get_run_dir(self) -> str:
"""Return the directory where the data from this run is stored"""
if self.__run_dir is None:
task = self.get_task()
project = task.get_project()
Expand Down
Loading
Loading