Skip to content

Commit

Permalink
Merge pull request #1266 from facebookresearch/fix-in-house-provider-…
Browse files Browse the repository at this point in the history
…auto-redirect

Fixed auto-redirect upon Task completion in In-House provider
  • Loading branch information
meta-paul authored Dec 12, 2024
2 parents 9fab428 + f2f3c51 commit 887eac2
Show file tree
Hide file tree
Showing 93 changed files with 824 additions and 770 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/cypress-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,9 @@ jobs:

- name: 🔪 Killing the web server
run: |
sudo apt install procps -y # Installing `pkill`
sudo pkill -9 python
sudo pkill -9 node
echo "Web server killed"
kill -INT $(lsof -i -P -n | grep LISTEN | grep python | awk '{print $2}')
kill -INT $(lsof -i -P -n | grep LISTEN | grep node | awk '{print $2}')
echo "Web server was killed"
- name: 🥛 Expiring units
run: |
Expand All @@ -585,7 +584,7 @@ jobs:
# run: |
# cd mephisto/scripts/local_db
# python review_tips_for_task.py << EOF
# react-static-task-with-tips
# react-static-task-with-worker-opinion
# a
# 5
# The tip is very informative
Expand All @@ -598,7 +597,7 @@ jobs:
# run: |
# cd mephisto/scripts/local_db
# python remove_accepted_tip.py << EOF
# react-static-task-with-tips
# react-static-task-with-worker-opinion
# n
# y
# EOF
Expand All @@ -607,15 +606,15 @@ jobs:
# run: |
# cd mephisto/scripts/local_db
# python review_feedback_for_task.py << EOF
# react-static-task-with-tips
# react-static-task-with-worker-opinion
# 0
# n
# u
# y
# y
# EOF
# python review_feedback_for_task.py << EOF
# react-static-task-with-tips
# react-static-task-with-worker-opinion
# 1
# n
# u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
@task_script(default_config_file="example__local__inhouse")
def main(operator: Operator, cfg: DictConfig) -> None:
os.environ["REACT_APP__WITH_WORKER_OPINION"] = "true"

examples.build_form_composer_simple(
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)

operator.launch_task_run(cfg.mephisto)
operator.wait_for_runs_then_shutdown(skip_input=True, log_rate=30)

Expand Down
4 changes: 2 additions & 2 deletions examples/form_composer_demo/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/form_composer_demo/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form_composer_demo",
"version": "2.0.0",
"version": "3.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
Expand Down
45 changes: 24 additions & 21 deletions examples/form_composer_demo/webapp/src/app_dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,47 @@
* LICENSE file in the root directory of this source tree.
*/

import { ErrorBoundary, useMephistoTask } from "mephisto-core";
import { MephistoApp } from "mephisto-addons";
import { useMephistoTask } from "mephisto-core";
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
FormComposerBaseFrontend,
LoadingScreen,
} from "./components/core_components_dynamic";

/* ================= Application Components ================= */

function MainApp() {
function App() {
const {
isLoading,
initialTaskData,
handleSubmit,
handleFatalError,
handleSubmit,
initialTaskData,
isLoading,
providerType,
}: {
isLoading: boolean;
initialTaskData: ConfigTaskType;
handleSubmit: Function;
handleFatalError: Function;
handleSubmit: Function;
initialTaskData: ConfigTaskType;
isLoading: boolean;
providerType: string;
} = useMephistoTask();

if (isLoading || !initialTaskData) {
if (isLoading) {
return <LoadingScreen />;
}

return (
<div>
<ErrorBoundary handleError={handleFatalError}>
<FormComposerBaseFrontend
taskData={initialTaskData}
onSubmit={handleSubmit}
onError={handleFatalError}
/>
</ErrorBoundary>
</div>
<MephistoApp
handleFatalError={handleFatalError}
hasTaskSpecificData={!!initialTaskData?.form}
providerType={providerType}
>
<FormComposerBaseFrontend
taskData={initialTaskData}
onSubmit={handleSubmit}
onError={handleFatalError}
/>
</MephistoApp>
);
}

ReactDOM.render(<MainApp />, document.getElementById("app"));
ReactDOM.render(<App />, document.getElementById("app"));
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,55 @@
* LICENSE file in the root directory of this source tree.
*/

import { ErrorBoundary, useMephistoRemoteProcedureTask } from "mephisto-core";
import { MephistoApp } from "mephisto-addons";
import { useMephistoRemoteProcedureTask } from "mephisto-core";
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
FormComposerBaseFrontend,
LoadingScreen,
} from "./components/core_components_dynamic_remote_procedure";

/* ================= Application Components ================= */

function MainApp() {
function App() {
const {
isLoading,
handleFatalError,
handleSubmit,
initialTaskData,
isLoading,
providerType,
remoteProcedure,
handleSubmit,
handleFatalError,
}: {
isLoading: boolean;
handleFatalError: Function;
handleSubmit: Function;
initialTaskData: ConfigTaskType;
isLoading: boolean;
providerType: string;
remoteProcedure: RemoteProcedureCollectionType;
handleSubmit: Function;
handleFatalError: Function;
} = useMephistoRemoteProcedureTask();

if (isLoading || !initialTaskData) {
if (isLoading) {
return <LoadingScreen />;
}

let _initialTaskData: ConfigTaskType = initialTaskData;
if (initialTaskData.hasOwnProperty("task_data")) {
if (initialTaskData && initialTaskData.hasOwnProperty("task_data")) {
_initialTaskData = initialTaskData.task_data;
}

return (
<div>
<ErrorBoundary handleError={handleFatalError}>
<FormComposerBaseFrontend
taskData={_initialTaskData}
onSubmit={handleSubmit}
onError={handleFatalError}
remoteProcedure={remoteProcedure}
/>
</ErrorBoundary>
</div>
<MephistoApp
handleFatalError={handleFatalError}
hasTaskSpecificData={!!_initialTaskData?.form}
providerType={providerType}
>
<FormComposerBaseFrontend
taskData={_initialTaskData}
onSubmit={handleSubmit}
onError={handleFatalError}
remoteProcedure={remoteProcedure}
/>
</MephistoApp>
);
}

ReactDOM.render(<MainApp />, document.getElementById("app"));
ReactDOM.render(<App />, document.getElementById("app"));
Loading

0 comments on commit 887eac2

Please sign in to comment.