Skip to content

Commit

Permalink
Merge pull request #1255 from facebookresearch/address-lack-of-packag…
Browse files Browse the repository at this point in the history
…e-builds

Reorganized local builds of Mephisto packages
  • Loading branch information
meta-paul authored Oct 16, 2024
2 parents 66a9d0b + d8f3fa5 commit 672a8f2
Show file tree
Hide file tree
Showing 129 changed files with 8,814 additions and 16,283 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/cypress-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
tools: ${{ steps.filter.outputs.tools }}
mephisto-task: ${{ steps.filter.outputs.mephisto-task }}
mephisto-worker-addons: ${{ steps.filter.outputs.mephisto-worker-addons }}
mephisto-core: ${{ steps.filter.outputs.mephisto-core }}
mephisto-addons: ${{ steps.filter.outputs.mephisto-addons }}
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -66,6 +68,10 @@ jobs:
- 'packages/mephisto-task/src/**'
mephisto-worker-addons:
- 'packages/mephisto-worker-addons/src/**'
mephisto-core:
- 'packages/mephisto-core/src/**'
mephisto-addons:
- 'packages/mephisto-addons/src/**'
# Learn more about this test here: https://github.com/facebookresearch/Mephisto/pull/881
simple_static_task:
Expand Down Expand Up @@ -307,7 +313,7 @@ jobs:
# Learn more about this test here: https://github.com/facebookresearch/Mephisto/pull/833
static_react_task_with_worker_opinion:
needs: changes
if: ${{ (needs.changes.outputs.static_react_task_with_worker_opinion == 'true') || (needs.changes.outputs.mephisto-task == 'true') || (needs.changes.outputs.mephisto-task-addons == 'true') || (needs.changes.outputs.abstractions == 'true') || (needs.changes.outputs.data_model == 'true') || (needs.changes.outputs.operations == 'true') || (needs.changes.outputs.tools == 'true')}}
if: ${{ (needs.changes.outputs.static_react_task_with_worker_opinion == 'true') || (needs.changes.outputs.mephisto-task == 'true') || (needs.changes.outputs.mephisto-addons == 'true') || (needs.changes.outputs.abstractions == 'true') || (needs.changes.outputs.data_model == 'true') || (needs.changes.outputs.operations == 'true') || (needs.changes.outputs.tools == 'true')}}
runs-on: ubuntu-latest
steps:
- name: 🔀 Checking out repo
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ mephisto/server/blueprints/**/build/*

**/*.log
**/build/*
!**/packages/mephisto-core/build/*
!**/packages/mephisto-addons/build/*
**/_generated/*
**/outputs/*
mephisto/scripts/metrics/*
Expand Down
2 changes: 1 addition & 1 deletion docs/web/docs/explanations/architecture_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ This is a quick guide over file directories in Mephisto project. Note that some
- `review_app` - builds React app for TaskReview, and launches a server to display TaskReview in a browser
- `outputs` - exhaust produced by running the code (logs, database dumps, etc)
- `packages` - npm packages (can be used locally, and some are also in npm repo)
- `mephisto-task-addons` - package for FC React component
- `mephisto-addons` - package with FC React component
- `scripts` - command-line utilities for code upkeep
- `test` - All tests (Back-end and Front-end, Unittests and Integration tests)
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ During development of your form config, you can use a few available helper funct

Example of use:

1. Add `mephisto-task-addons` in webpack config
1. Add `mephisto-addons` in webpack config

```js
resolve: {
alias: {
...
"mephisto-task-addons": path.resolve(
"mephisto-addons": path.resolve(
__dirname,
"<relativePath>/packages/mephisto-task-addons"
"<relativePath>/packages/mephisto-addons"
),
},
}
```
2. Add import
```js
import { validateFieldValue } from "mephisto-task-addons";
import { validateFieldValue } from "mephisto-addons";
```
3. Validate a value before assigning it to form field
```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ During development of your annotator config, you can use a few available helper

Example of use:

1. Add `mephisto-task-addons` in webpack config
1. Add `mephisto-addons` in webpack config

```js
resolve: {
alias: {
...
"mephisto-task-addons": path.resolve(
"mephisto-addons": path.resolve(
__dirname,
"<relativePath>/packages/mephisto-task-addons"
"<relativePath>/packages/mephisto-addons"
),
},
}
```
2. Add import
```js
import { validateFieldValue } from "mephisto-task-addons";
import { validateFieldValue } from "mephisto-addons";
```
3. Validate a value before assigning it to segment field
```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ sidebar_position: 1

## Overview

The `mephisto-task-addons` package provides:
The `mephisto-addons` package provides:
- `WorkerOpinion` widget: collect workers' feedback for each completed unit

## Usage

1. Add `mephisto-task-addons` library to your webpack config:
1. Add `mephisto-addons` library to your webpack config:
```js
// Specifies location of your packages (e.g. `../../dir`)
var PATH_TO_PACKAGES = "<path>"
Expand All @@ -26,19 +26,19 @@ module.exports = {
resolve: {
alias: {
...
"mephisto-task-addons": path.resolve(
"mephisto-addons": path.resolve(
__dirname,
`${PATH_TO_PACKAGES}/packages/mephisto-task-addons`
`${PATH_TO_PACKAGES}/packages/mephisto-addons`
),
}
}
};
```

2. Import desired widgets from `mephisto-task-addons` in your code like so:
2. Import desired widgets from `mephisto-addons` in your code like so:

```jsx
import { WorkerOpinion } from "mephisto-task-addons";
import { WorkerOpinion } from "mephisto-addons";
...
<WorkerOpinion
maxTextLength={500}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WorkerOpinion widget currently may contain a set of textarea form fields, and a

## How to enable `WorkerOpinion`

1. Add `mephisto-task-addons` library to your webpack config
1. Add `mephisto-addons` library to your webpack config
2. Import `WorkerOpinion` component to your Task's React application code and define questions.

### 1. Webpack config
Expand All @@ -30,9 +30,9 @@ module.exports = {
resolve: {
alias: {
...
"mephisto-task-addons": path.resolve(
"mephisto-addons": path.resolve(
__dirname,
`${PATH_TO_PACKAGES}/packages/mephisto-task-addons`
`${PATH_TO_PACKAGES}/packages/mephisto-addons`
),
}
}
Expand All @@ -42,7 +42,7 @@ module.exports = {
### 2. `WorkerOpinion` component

```jsx
import { WorkerOpinion } from "mephisto-task-addons";
import { WorkerOpinion } from "mephisto-addons";
...
return(
<div ...>
Expand Down Expand Up @@ -75,4 +75,4 @@ Here's how `WorkerOpinion` component looks like:

1. After completing each unit, workers can submit an opinion about the completed unit.
2. **Once the task is shut down**, you can review all collected opinions for the task in TaskReview app.
3. When reviewing units in TaskReview app, you will see an extra accordion section "Worker Opinion" if a worker submitted their opinion.
3. When reviewing units in TaskReview app, you will see an extra accordion section "Worker Opinion" if a worker submitted their opinion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// NOTE: that `mephisto-task-addons` library must be set in webpack config as an alias.
import { validateFieldValue } from "mephisto-task-addons";
// NOTE: that `mephisto-addons` library must be set in webpack config as an alias.
import { validateFieldValue } from "mephisto-addons";

export function onChangeCountry(
formData, // React state for the entire form
Expand Down
2 changes: 1 addition & 1 deletion examples/form_composer_demo/webapp/src/app_dynamic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FormComposerBaseFrontend,
LoadingScreen,
} from "./components/core_components_dynamic.jsx";
import { useMephistoTask, ErrorBoundary } from "mephisto-task-multipart";
import { useMephistoTask, ErrorBoundary } from "mephisto-core";

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

Expand Down
4 changes: 2 additions & 2 deletions examples/form_composer_demo/webapp/src/app_simple.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* LICENSE file in the root directory of this source tree.
*/

import { WorkerOpinion } from "mephisto-task-addons";
import { ErrorBoundary, useMephistoTask } from "mephisto-task-multipart";
import { WorkerOpinion } from "mephisto-addons";
import { ErrorBoundary, useMephistoTask } from "mephisto-core";
import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom";
import { BrowserRouter, Route, Routes } from "react-router-dom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from "react";
import { FormComposer } from "mephisto-task-addons";
import { FormComposer } from "mephisto-addons";

// Required import for custom validators
import * as customValidators from "custom-validators";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
FormComposer,
prepareFormData,
prepareRemoteProcedures,
} from "mephisto-task-addons";
} from "mephisto-addons";

function LoadingScreen() {
return <Directions>Loading...</Directions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React from "react";
import { FormComposer } from "mephisto-task-addons";
import { FormComposer } from "mephisto-addons";

function LoadingScreen() {
return <Directions>Loading...</Directions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
FormComposerBaseFrontend,
LoadingScreen,
} from "./components/core_components_presigned_url.jsx";
import {
useMephistoRemoteProcedureTask,
ErrorBoundary,
} from "mephisto-task-multipart";
import { useMephistoRemoteProcedureTask, ErrorBoundary } from "mephisto-core";

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

Expand Down
10 changes: 5 additions & 5 deletions examples/form_composer_demo/webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../packages/mephisto-task-multipart"
"../../../packages/mephisto-core"
),
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-task-addons": path.resolve(
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-addons": path.resolve(
__dirname,
"../../../packages/mephisto-task-addons"
"../../../packages/mephisto-addons"
),
...dynamicAliases,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../packages/mephisto-task-multipart"
"../../../packages/mephisto-core"
),
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-task-addons": path.resolve(
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-addons": path.resolve(
__dirname,
"../../../packages/mephisto-task-addons"
"../../../packages/mephisto-addons"
),
},
fallback: {
Expand Down
6 changes: 3 additions & 3 deletions examples/form_composer_demo/webapp/webpack.config.review.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ module.exports = {
resolve: {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-task-addons": path.resolve(
// Use local library with code that can use FormComposer and submit Worker Opinion
"mephisto-addons": path.resolve(
__dirname,
"../../../packages/mephisto-task-addons"
"../../../packages/mephisto-addons"
),
...dynamicAliases,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/remote_procedure/mnist/webapp/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MephistoContext,
useMephistoRemoteProcedureTask,
ErrorBoundary,
} from "mephisto-task-multipart";
} from "mephisto-core";

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

Expand Down
4 changes: 2 additions & 2 deletions examples/remote_procedure/mnist/webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../../packages/mephisto-task-multipart"
"../../../../packages/mephisto-core"
),
},
fallback: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../../packages/mephisto-task-multipart"
"../../../../packages/mephisto-core"
),
},
fallback: {
Expand Down
2 changes: 1 addition & 1 deletion examples/remote_procedure/template/webapp/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
MephistoContext,
useMephistoRemoteProcedureTask,
ErrorBoundary,
} from "mephisto-task-multipart";
} from "mephisto-core";

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

Expand Down
4 changes: 2 additions & 2 deletions examples/remote_procedure/template/webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../../packages/mephisto-task-multipart"
"../../../../packages/mephisto-core"
),
},
fallback: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MephistoContext,
useMephistoRemoteProcedureTask,
ErrorBoundary,
} from "mephisto-task-multipart";
} from "mephisto-core";

function RemoteProcedureApp() {
let mephistoProps = useMephistoRemoteProcedureTask({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ module.exports = {
alias: {
react: path.resolve("./node_modules/react"),
// Use local library with code that can submit FormData
"mephisto-task-multipart": path.resolve(
"mephisto-core": path.resolve(
__dirname,
"../../../../packages/mephisto-task-multipart"
"../../../../packages/mephisto-core"
),
},
fallback: {
Expand Down
2 changes: 1 addition & 1 deletion examples/static_react_task_with_worker_opinion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The [static-react-task README](../static_react_task/README.md) should be read be

### Adding `WorkerOpinion` widget

To see how to add this widget, read [mephisto-task-addons README](../../packages/mephisto-task-addons/README.md)
To see how to add this widget, read [mephisto-addons README](packages/mephisto-addons/README.md)

Once a worker submits an opinion from the form below the main task that will be available to the researcher in TaskReview app.
There is a page with all opinions for a Task and "Worker Opinion" collapsable block on Unit review page if a worker left their opinion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
* LICENSE file in the root directory of this source tree.
*/

export const workerOpinionClassNamePrefix =
"mephisto-task-addons-worker-opinion__";
export const workerOpinionClassNamePrefix = "mephisto-addons-worker-opinion__";
export const tipClassNamePrefix = "mephisto-worker-addons-tips__";
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
OnboardingComponent,
LoadingScreen,
} from "./components/core_components.jsx";
import { useMephistoTask, ErrorBoundary } from "mephisto-task-multipart";
import { useMephistoTask, ErrorBoundary } from "mephisto-core";

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

Expand Down
Loading

0 comments on commit 672a8f2

Please sign in to comment.