Skip to content

Commit

Permalink
Removed deprecated mephisto-task and mephisto-worker-addons libs
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Nov 13, 2024
1 parent b09f8ec commit bfcdd09
Show file tree
Hide file tree
Showing 125 changed files with 14,504 additions and 46,126 deletions.
238 changes: 203 additions & 35 deletions .github/workflows/cypress-end-to-end-tests.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/version-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: Install Mephisto
run: pip install -e .
- name: Run version sync script
run: python scripts/sync_mephisto_task.py check
run: python scripts/sync_mephisto_core.py check
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ There is a way to fix this:
* Make sure to reset the baseUrl back to default("/") if contributing to the repo as the GitHub action will fail otherwise.

## Local Package Development
If you are modifying either the `mephisto-task` or `mephisto-worker-addons` packages you probably want to see your changes propagate to the task that you are working on.
If you are modifying either the `mephisto-core` or `mephisto-addons` packages you probably want to see your changes propagate to the task that you are working on.

The easiest way to do this is to run a task by doing:
```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- Are you interested in a simple task with barebones HTML files? Reference the **[simple static task](/examples/static_static_task/)**.

- Are you interested in building a rich frontend? Learn about how you can create a **[simple React task](/examples/static_react_task/)**.
- Reference the docs for the **[`mephisto-task` helper package](/packages/mephisto-task/README.md)** for interfacing with the Mephisto server.
- Reference the docs for the **[`mephisto-core` helper package](/packages/mephisto-core/README.md)** for interfacing with the Mephisto server.
- You may also want to use components offered in the **[`annotation-toolkit` component library](/packages/annotation-toolkit/README.md)** to get up-and-running quick. The components of the library can be **[demoed in the storybook](https://annotation-toolkit-storybook.vercel.app/)**.

- Are you interested in dialogue-based tasks using the ParlAI framework? You may want to check out the **[example ParlAI demo task](/examples/parlai_chat_task_demo/)**. For UI customizations, we heavily use the **[`bootstrap-chat` helper package](/packages/bootstrap-chat/)**, so you may want to reference the documentation for that as well.
3 changes: 1 addition & 2 deletions docs/legacy/upgrade_to_v1/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ sidebar_position: 1
- Or if you set up Mephisto using the pip wheel: `pip install Mephisto -U`
2. Ensure that your front-end code is using the latest packages, by running the following **in your task's webapp folder**.
```bash
npm install --save mephisto-task@2
npm install --save bootstrap-chat@2 # if applicable
```
3. For webapps using `mephisto-task`: Migrate any usage of `sendMessage` in your front-end code to `sendLiveUpdate`.
3. For webapps using `mephisto-core`: Migrate any usage of `sendMessage` in your front-end code to `sendLiveUpdate`.
4. [Migrate your run scripts](../run_scripts) to use the newly introduced syntax, aimed to reduce boilerplate.


Expand Down
4 changes: 2 additions & 2 deletions docs/web/docs/explanations/architect_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ While this is the "Architect API" most of the responsibilities for the architect

The primary responsiblity of the router is to take incoming packets from client connections and direct them to the core Mephisto `ClientIOHandler` and to do the reverse as well. All packets will have a core `agent_id` field denoting either the sender or receiver of the packet, depending on the packet type. The only exception is the `PACKET_TYPE_ALIVE`, which is directed to the router and allows for any registration of an incoming connection.

Secondarily, the router is responsible for converting RESTful `POST` requests from `mephisto-task` into socket messages, and relaying the response as a standard `POST` response. This behavior is _only_ for the `PACKET_TYPE_REGISTER_AGENT`, and `PACKET_TYPE_SUBMIT_ONBOARDING` packets, and both of them will be serviced by `PACKET_TYPE_AGENT_DETAILS` responses. For these it should be listening to `POST` requests at `/register_worker`, `/submit_onboarding`, and `/submit_task`. `POST` requests to `/log_error` should result in forwarding a `PACKET_TYPE_ERROR`.
Secondarily, the router is responsible for converting RESTful `POST` requests from `mephisto-core` into socket messages, and relaying the response as a standard `POST` response. This behavior is _only_ for the `PACKET_TYPE_REGISTER_AGENT`, and `PACKET_TYPE_SUBMIT_ONBOARDING` packets, and both of them will be serviced by `PACKET_TYPE_AGENT_DETAILS` responses. For these it should be listening to `POST` requests at `/register_worker`, `/submit_onboarding`, and `/submit_task`. `POST` requests to `/log_error` should result in forwarding a `PACKET_TYPE_ERROR`.

Third, the router is responsible for maintaining track of agent status, and acting as a cache for this information after disconnects. This allows for a worker to return to a task and have updated information about what has transpired, even when the main Mephisto server has cleaned up the related `TaskRunner` and live `Agent`.

Fourth, the router is responsible for serving the static `task_config.json` file, which allows the frontend to load certain details about the full task before going through any registration handshakes.

### `mephisto-task` responsibilities.
### `mephisto-core` responsibilities.

The `useMephistoTask` hook is responsible for allowing a worker to connect to a task and submit the relevant data. For this, it only needs to make `POST` requests related to the `PACKET_TYPE_SUBMIT_*` and `PACKET_TYPE_REGISTER_AGENT` events. The former should be triggered on `handleSubmit`, while the latter should trigger immediately on load.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ sidebar_position: 1

# Developing and debugging frontends

## The `mephisto-task` package
## The `mephisto-core` package

We provide the `mephisto-task` package for use in your front-end React tasks.
We provide the `mephisto-core` package for use in your front-end React tasks.

To install, add it to your npm project as such:

```
npm install mephisto-task
```

The `mephisto-task` project surfaces three React hooks depending on your use case:
The `mephisto-core` project surfaces three React hooks depending on your use case:

1. `useMephistoTask` - Used for static tasks where one-time initial data is enough to power the task. See the example task in `/examples/static_react_task/` for an example project using this hook.
2. `useMephistoLiveTask` - Used for multi-turn, socket-based tasks, such as a dialogue task. See the example task in `/examples/parlai_chat_task_demo/` for an example project using this hook.
3. `useMephistoRemoteProcedureTask` - Used for static tasks that require access to some remote function on the back-end, for example invoking a back-end model for model-assisted annotation. See the example task in `/examples/remote_procedure/mnist/` for an example project using this hook.

Complete documentation for each of the hooks can be found in the [associated README for the `mephisto-task` package](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-task).
Complete documentation for each of the hooks can be found in the [associated README for the `mephisto-core` package](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-core).

## Reusable UI component libraries

Expand Down Expand Up @@ -54,7 +48,7 @@ Currently, we have beta functionality for error handling. We provide a few ways
For #1 above, auto-logging can be enabled for React apps by importing the `<ErrorBoundary />` component and wiring it up as such:

```jsx
import { ErrorBoundary } from "mephisto-task";
import { ErrorBoundary } from "mephisto-core";
...
const { handleFatalError, /* ... */ } = useMephistoTask();
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Unlike Screening and Gold units, Onboarding expects that you set up a custom fro
You want to provide workers with an in-depth exploration of your task up-front
(though you can always re-use onboarding components in your main task as reference materials).

The handleSubmit method of `mephisto-task` is used to send onboarding data from frontend to backend.
The handleSubmit method of `mephisto-core` is used to send onboarding data from frontend to backend.
For more info on how to build out onboarding frontends, check out our [tutorial](../../../tutorials/worker_controls).

**Note:** We've observed that some workers may share out the answers for onboarding tasks,
Expand Down
2 changes: 1 addition & 1 deletion docs/web/docs/guides/tutorials/custom_react.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function MainApp() {
isOnboarding,
} = useMephistoTask();
```
Any Mephisto frontend task relies on either the `useMephistoTask` or `useMephistoLiveTask` hooks to get underlying state about the worker and the task. For now it's only important to note that we pull `initialTaskData` from Mephisto, as well as a `handleSubmit` function. (More details on usage of these hooks is available [here](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-task).)
Any Mephisto frontend task relies on either the `useMephistoTask` or `useMephistoLiveTask` hooks to get underlying state about the worker and the task. For now it's only important to note that we pull `initialTaskData` from Mephisto, as well as a `handleSubmit` function. (More details on usage of these hooks is available [here](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-core).)
```javascript
if (blockedReason !== null) {
return ...
Expand Down
6 changes: 3 additions & 3 deletions docs/web/docs/reference/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Other sections of the documentation may soon be auto-generated.

In the meanwhile, you may find reference documentation in the following locations:

- [`mephisto-task`](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-task) - This package provides two hooks to faciliate React-based front-end development for Mephisto tasks. Use `useMephistoTask` for simple, static tasks or `useMephistoLiveTask` for multi-turn, socket-based tasks.
- [`mephisto-worker-addons`](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-worker-addons) - This package provides the tips and feedback components to allow for collection of tips and feedback from workers.
- [`bootstrap-chat`](https://github.com/facebookresearch/Mephisto/tree/main/packages/bootstrap-chat)A set of UI components based on Bootstrap v3 for facilitating chat-based tasks for Mephisto.
- [`mephisto-core`](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-core) - This package provides two hooks to faciliate React-based front-end development for Mephisto tasks. Use `useMephistoTask` for simple, static tasks or `useMephistoLiveTask` for multi-turn, socket-based tasks.
- [`mephisto-addons`](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-addons) - A bunch of UI components to make Tasks more customizable.
- [`bootstrap-chat`](https://github.com/facebookresearch/Mephisto/tree/main/packages/bootstrap-chat) - A set of UI components based on Bootstrap v3 for facilitating chat-based tasks for Mephisto.
- [`annotation-toolkit` and `@annotated`](https://github.com/facebookresearch/Mephisto/tree/main/packages/annotation-toolkit) - This package helps users to build out review & annotation tooling for their research tasks. `annotation-toolkit` has been deprecated in favor of `@annotated`.
- [`cra-template-mephisto-review`](https://github.com/facebookresearch/Mephisto/tree/main/packages/cra-template-mephisto-review) - A customizable base template for creating data exploration interfaces with first-class support for the `mephisto review` command.
- [`mephisto-review-hook`](https://github.com/facebookresearch/Mephisto/tree/main/packages/mephisto-review-hook) - TODO
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h1 class="modulename">

<div class="docstring"><h1 id="router">router</h1>

<p>This directory contains all of the Mephisto code regarding setting up and deploying and endpoint that can handle interfacing with the <code>mephisto-task</code> package. As of now there are two implementations, a node server in <code>deploy</code> and a Flask server in <code>flask</code>. Each of these can be extended upon such that you can deploy your own server (with whatever logic you may need) but still have mephisto routing functionality.</p>
<p>This directory contains all of the Mephisto code regarding setting up and deploying and endpoint that can handle interfacing with the <code>mephisto-core</code> package. As of now there are two implementations, a node server in <code>deploy</code> and a Flask server in <code>flask</code>. Each of these can be extended upon such that you can deploy your own server (with whatever logic you may need) but still have mephisto routing functionality.</p>

<h2 id="build_routerpy"><code>build_router.py</code></h2>

Expand Down Expand Up @@ -294,4 +294,4 @@ <h1 id="routing-implementation-functionality-and-gotchas">Routing implementation
}
});
</script></body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h1 class="modulename">
<span class="n">FLASK_SERVER_SOURCE_ROOT</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ROUTER_ROOT_DIR</span><span class="p">,</span> <span class="s2">&quot;flask&quot;</span><span class="p">)</span>
<span class="n">CROWD_SOURCE_PATH</span> <span class="o">=</span> <span class="s2">&quot;static/wrap_crowd_source.js&quot;</span>
<span class="n">TASK_CONFIG_PATH</span> <span class="o">=</span> <span class="s2">&quot;static/task_config.json&quot;</span>
<span class="n">CURR_MEPHISTO_TASK_VERSION</span> <span class="o">=</span> <span class="s2">&quot;2.0.0&quot;</span>
<span class="n">CURR_MEPHISTO_CORE_PACKAGE_VERSION</span> <span class="o">=</span> <span class="s2">&quot;1.5.1&quot;</span>


<span class="k">def</span> <span class="nf">can_build</span><span class="p">(</span><span class="n">build_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">task_run</span><span class="p">:</span> <span class="s2">&quot;TaskRun&quot;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
Expand Down Expand Up @@ -179,7 +179,7 @@ <h1 class="modulename">
<span class="n">blueprint</span> <span class="o">=</span> <span class="n">task_run</span><span class="o">.</span><span class="n">get_blueprint</span><span class="p">()</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">local_task_config_path</span><span class="p">,</span> <span class="s2">&quot;w+&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">task_fp</span><span class="p">:</span>
<span class="n">frontend_args</span> <span class="o">=</span> <span class="n">blueprint</span><span class="o">.</span><span class="n">get_frontend_args</span><span class="p">()</span>
<span class="n">frontend_args</span><span class="p">[</span><span class="s2">&quot;mephisto_task_version&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CURR_MEPHISTO_TASK_VERSION</span>
<span class="n">frontend_args</span><span class="p">[</span><span class="s2">&quot;mephisto_core_version&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CURR_MEPHISTO_CORE_PACKAGE_VERSION</span>
<span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">frontend_args</span><span class="p">,</span> <span class="n">task_fp</span><span class="p">)</span>

<span class="c1"># Consolidate task files as defined by the task</span>
Expand Down Expand Up @@ -365,7 +365,7 @@ <h1 class="modulename">
<span class="n">blueprint</span> <span class="o">=</span> <span class="n">task_run</span><span class="o">.</span><span class="n">get_blueprint</span><span class="p">()</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">local_task_config_path</span><span class="p">,</span> <span class="s2">&quot;w+&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">task_fp</span><span class="p">:</span>
<span class="n">frontend_args</span> <span class="o">=</span> <span class="n">blueprint</span><span class="o">.</span><span class="n">get_frontend_args</span><span class="p">()</span>
<span class="n">frontend_args</span><span class="p">[</span><span class="s2">&quot;mephisto_task_version&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CURR_MEPHISTO_TASK_VERSION</span>
<span class="n">frontend_args</span><span class="p">[</span><span class="s2">&quot;mephisto_core_version&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CURR_MEPHISTO_CORE_PACKAGE_VERSION</span>
<span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">frontend_args</span><span class="p">,</span> <span class="n">task_fp</span><span class="p">)</span>

<span class="c1"># Consolidate task files as defined by the task</span>
Expand Down Expand Up @@ -565,4 +565,4 @@ <h1 class="modulename">
}
});
</script></body>
</html>
</html>
Loading

0 comments on commit bfcdd09

Please sign in to comment.