-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated WorkerOpinion feature to TaskReview app; Added example of …
…WorkerOpinion implementation
- Loading branch information
Showing
46 changed files
with
2,568 additions
and
1,847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
examples/form_composer_demo/run_task_with_worker_opinion.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Meta Platforms and its affiliates. | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import os | ||
|
||
from omegaconf import DictConfig | ||
|
||
from mephisto.operations.operator import Operator | ||
from mephisto.tools.scripts import build_custom_bundle | ||
from mephisto.tools.scripts import task_script | ||
|
||
|
||
@task_script(default_config_file="example_local_mock") | ||
def main(operator: Operator, cfg: DictConfig) -> None: | ||
os.environ["REACT_APP__WITH_WORKER_OPINION"] = "true" | ||
|
||
# Build packages | ||
_build_custom_bundles(cfg) | ||
|
||
operator.launch_task_run(cfg.mephisto) | ||
operator.wait_for_runs_then_shutdown(skip_input=True, log_rate=30) | ||
|
||
|
||
def _build_custom_bundles(cfg: DictConfig) -> None: | ||
"""Locally build bundles that are not available on npm repository""" | ||
mephisto_packages_dir = os.path.join( | ||
# Root project directory | ||
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), | ||
"packages", | ||
) | ||
|
||
# Build `mephisto-task-multipart` React package | ||
build_custom_bundle( | ||
mephisto_packages_dir, | ||
force_rebuild=cfg.mephisto.task.force_rebuild, | ||
webapp_name="mephisto-task-multipart", | ||
build_command="build", | ||
) | ||
|
||
# Build `mephisto-task-addons` React package | ||
build_custom_bundle( | ||
mephisto_packages_dir, | ||
force_rebuild=cfg.mephisto.task.force_rebuild, | ||
webapp_name="mephisto-task-addons", | ||
build_command="build", | ||
) | ||
|
||
# Build `react-form-composer` React package | ||
build_custom_bundle( | ||
mephisto_packages_dir, | ||
force_rebuild=cfg.mephisto.task.force_rebuild, | ||
webapp_name="react-form-composer", | ||
build_command="build", | ||
) | ||
|
||
# Build Review UI for the application | ||
build_custom_bundle( | ||
cfg.task_dir, | ||
force_rebuild=cfg.mephisto.task.force_rebuild, | ||
webapp_name="webapp", | ||
build_command="build:simple:review", | ||
) | ||
|
||
# Build Task UI for the application | ||
build_custom_bundle( | ||
cfg.task_dir, | ||
force_rebuild=cfg.mephisto.task.force_rebuild, | ||
post_install_script=cfg.mephisto.task.post_install_script, | ||
build_command="dev:simple", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.