Skip to content

Commit

Permalink
Merge pull request #1227 from facebookresearch/add-in-house-provider
Browse files Browse the repository at this point in the history
Add a new "InHouse" provider for working with internal crowd
  • Loading branch information
meta-paul authored Aug 15, 2024
2 parents da44395 + 4dc823f commit 213cefa
Show file tree
Hide file tree
Showing 53 changed files with 1,777 additions and 154 deletions.
1 change: 1 addition & 0 deletions docker/entrypoints/server.mturk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mkdir -p "data" && chmod 777 "data"
# Directory for Cypress testing
mkdir -p "/root/.cache/Cypress" && chmod 777 "/root/.cache/Cypress"

mephisto register inhouse name=inhouse
mephisto register mturk_sandbox \
name=$MTURK_SANDBOX_NAME \
access_key_id=$MTURK_SANDBOX_ACCESS_KEY_ID \
Expand Down
1 change: 1 addition & 0 deletions docker/entrypoints/server.prolific.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mkdir -p "data" && chmod 777 "data"
# Directory for Cypress testing
mkdir -p "/root/.cache/Cypress" && chmod 777 "/root/.cache/Cypress"

mephisto register inhouse name=inhouse
mephisto register prolific name=prolific api_key=$PROLIFIC_API_KEY

exec "$@"
8 changes: 8 additions & 0 deletions docs/web/docs/guides/how_to_use/form_composer/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ First ensure that mephisto package is installed locally - please refer to [Mephi
Once that is done, run [`form_composer config` command](/docs/guides/how_to_use/form_composer/configuration/form_composer_config_command/) if needed, followed by `form_composer` command:

```shell
# Configure command (for details, see "form_composer config command" page)
mephisto form_composer config --extrapolate-token-sets

# Run commands
mephisto form_composer
mephisto form_composer --task-data-config-only
mephisto form_composer --conf my-yaml-config
```

where
- `-o/--task-data-config-only` - validate only final data config
- `-c/--conf` - YAML config name (analog of `conf` option in raw python run script)
4 changes: 2 additions & 2 deletions docs/web/docs/guides/how_to_use/review_app/diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

sidebar_position: 5
sidebar_position: 6
---

# TaskReview app diagram
# TaskReview app flow

Here is how TaskReview app works under the hood to enable review of Task results in a local web browser.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# 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.

sidebar_position: 4
---

# Enable Responses Histogram

Some tasks can display simple histograms with response frequencies.
To enable response frequency histograms, add a tag `form-composer` in the Task's YAML config under `mephisto.task.task_tags` section.

**Note** that currently this feature is supported only by FormComposer-based Tasks.

Example YAML config:

```yaml
mephisto:
...
task:
task_name: "My form-based task"
...
task_tags: "my-tag-1,my-tag-2,form-composer"
```
This is how histograms typically look like:
![Task statistics](./screenshots/task_stats.png)
6 changes: 4 additions & 2 deletions docs/web/docs/guides/how_to_use/review_app/server_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

sidebar_position: 4
sidebar_position: 5
---

# TaskReview app API
Expand Down Expand Up @@ -57,7 +57,9 @@ Get all available tasks (to select one for review)
"id": <int>,
"is_reviewed": <bool>,
"name": <str>,
"unit_count": <int>
"unit_all_count": <int>,
"unit_completed_count": <int>,
"unit_finished_count": <int>
},
... // more tasks
]
Expand Down
127 changes: 127 additions & 0 deletions examples/form_composer_demo/data/simple/task_data_short.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
[
{
"form": {
"title": "Form example",
"instruction": "Please answer all questions to the best of your ability as part of our study.",
"sections": [
{
"name": "section_about",
"title": "About you",
"instruction": "Please introduce yourself. We would like to know more about your background, personal information, etc.",
"fieldsets": [
{
"title": "Personal information",
"instruction": "",
"rows": [
{
"fields": [
{
"help": "",
"id": "id_name_first",
"label": "First name",
"name": "name_first",
"placeholder": "Type first name",
"tooltip": "Your first name",
"type": "input",
"validators": {
"required": true,
"minLength": 2,
"maxLength": 20
},
"value": ""
},
{
"help": "Optional",
"id": "id_name_last",
"label": "Last name",
"name": "name_last",
"placeholder": "Type last name",
"tooltip": "Your last name",
"type": "input",
"validators": { "required": true },
"value": ""
}
],
"help": "Please use your legal name"
}
]
},
{
"title": "Cultural background",
"instruction": "Please tell us about your cultural affiliations and values that you use in your daily life.",
"rows": [
{
"fields": [
{
"help": "Select country of your residence",
"id": "id_country",
"label": "Country",
"multiple": false,
"name": "country",
"options": [
{
"label": "---",
"value": ""
},
{
"label": "United States of America",
"value": "USA"
},
{
"label": "Canada",
"value": "CAN"
}
],
"placeholder": "",
"tooltip": "Country",
"type": "select",
"validators": { "required": true },
"value": ""
},
{
"help": "Select language spoken in your local community",
"id": "id_language",
"label": "Language",
"multiple": true,
"name": "language",
"options": [
{
"label": "English",
"value": "en"
},
{
"label": "French",
"value": "fr"
},
{
"label": "Spanish",
"value": "es"
},
{
"label": "Chinese",
"value": "ch"
}
],
"placeholder": "",
"tooltip": "Language",
"type": "select",
"validators": {
"required": false
},
"value": ""
}
]
}
],
"help": "This information will help us compile study statistics"
}
]
}
],
"submit_button": {
"text": "Submit",
"tooltip": "Submit form"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#@package _global_

# 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.

defaults:
- /mephisto/blueprint: static_react_task
- /mephisto/architect: local
- /mephisto/provider: inhouse

mephisto:
blueprint:
data_json: ${task_dir}/data/simple/task_data_short.json
task_source: ${task_dir}/webapp/build/bundle.js
task_source_review: ${task_dir}/webapp/build/bundle.review.js
link_task_source: false
extra_source_dir: ${task_dir}/webapp/src/static
units_per_assignment: 2
provider:
ui_base_url: "http://localhost:3001"
task:
task_name: "Sample Questionnaire"
task_title: "Example how to easily create simple form-based Tasks"
task_description: "In this Task, we use FormComposer feature."
task_reward: 0
task_tags: "test,simple,form,form-composer,inhouse"
force_rebuild: true
25 changes: 25 additions & 0 deletions examples/form_composer_demo/run_task__local__inhouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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.

from omegaconf import DictConfig

from mephisto.operations.operator import Operator
from mephisto.tools.building_react_apps import examples
from mephisto.tools.scripts import task_script


@task_script(default_config_file="example_local_inhouse")
def main(operator: Operator, cfg: DictConfig) -> None:
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)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@task_script(default_config_file="example_local_mock")
def main(operator: Operator, cfg: DictConfig) -> None:
os.environ["REACT_APP__WITH_WORKER_OPINION"] = "true"
examples.build_form_composer_simple_with_worker_opinion(
examples.build_form_composer_simple(
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)
Expand Down
66 changes: 65 additions & 1 deletion 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.

3 changes: 2 additions & 1 deletion examples/form_composer_demo/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"jquery": "^3.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-overlay": "^6.0.11"
"react-error-overlay": "^6.0.11",
"react-router-dom": "^6.26.0"
},
"devDependencies": {
"@babel/cli": "^7.1.0",
Expand Down
Loading

0 comments on commit 213cefa

Please sign in to comment.