diff --git a/.github/workflows/cypress-end-to-end-tests.yml b/.github/workflows/cypress-end-to-end-tests.yml index a55303ffa..4888e52ec 100644 --- a/.github/workflows/cypress-end-to-end-tests.yml +++ b/.github/workflows/cypress-end-to-end-tests.yml @@ -110,7 +110,7 @@ jobs: browser: chrome project: ./mephisto/abstractions/blueprints/static_html_task/source config-file: ./cypress.config.js - start: python ./examples/simple_static_task/static_test_script.py + start: python ./examples/simple_static_task/run_task.py wait-on: "http://localhost:3000/?worker_id=x&assignment_id=1" headless: true diff --git a/docker/docker-compose.dev.vscode.yml b/docker/docker-compose.dev.vscode.yml index 56d7fea65..093bff840 100644 --- a/docker/docker-compose.dev.vscode.yml +++ b/docker/docker-compose.dev.vscode.yml @@ -30,6 +30,6 @@ services: /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 - /mephisto/examples/simple_static_task/static_test_script.py + /mephisto/examples/simple_static_task/run_task.py ", ] diff --git a/docs/web/docs/guides/how_to_use/efficiency_organization/docker.md b/docs/web/docs/guides/how_to_use/efficiency_organization/docker.md index 97c55f597..9c23ac179 100644 --- a/docs/web/docs/guides/how_to_use/efficiency_organization/docker.md +++ b/docs/web/docs/guides/how_to_use/efficiency_organization/docker.md @@ -10,7 +10,7 @@ Some users prefer to keep Mephisto entirely contained. Docker is one option for ```bash # Build the docker image and tag with name 'mephisto' -$ docker build -t mephisto . +$ docker build -t mephisto . # By default, the container just runs `mephisto check`: $ docker run mephisto @@ -18,7 +18,7 @@ Mephisto seems to be set up correctly. # You can also bind ports and pass in shell commands, e.g. to run # a task directly from the container -$ docker run -p 3000:3000 mephisto bash -c 'cd mephisto/examples/simple_static_task && python static_test_script.py' +$ docker run -p 3000:3000 mephisto bash -c 'cd mephisto/examples/simple_static_task && python run_task.py' ``` By default, Mephisto run data will be stored at `/mephisto/data` within the container. diff --git a/docs/web/docs/guides/tutorials/first_task.md b/docs/web/docs/guides/tutorials/first_task.md index 4b6f4218d..d77b55191 100644 --- a/docs/web/docs/guides/tutorials/first_task.md +++ b/docs/web/docs/guides/tutorials/first_task.md @@ -20,7 +20,7 @@ To get started, you can launch a task by executing a run script. For instance, l ```bash $ cd examples/simple_static_task -$ python static_test_script.py +$ python run_task.py ``` This will launch a local HTTP server with the task hosted, based on the default configuration options: @@ -31,13 +31,13 @@ defaults: - /mephisto/architect: local - /mephisto/provider: mock ``` -We'll dig into *how* this works [later](#33-default-abstraction-usage). +We'll dig into *how* this works [later](#33-default-abstraction-usage). ### 1.2 Access the task By default, the task should be hosted at `localhost:3000`. This default is set by the `LocalArchitect`, which is used based on the `- /mephisto/architect: local` line above. Navigating to this address should show you the preview view for the task. -Actually being able to access this task is done by providing `worker_id` and `assignment_id` URL params, like `localhost:3000/?worker_id=x&assignment_id=1` The `MockProvider` interprets these to be a test worker, which you can use to try out tasks. +Actually being able to access this task is done by providing `worker_id` and `assignment_id` URL params, like `localhost:3000/?worker_id=x&assignment_id=1` The `MockProvider` interprets these to be a test worker, which you can use to try out tasks. Try navigating here and completing a task by selecting a value (no need to use the file upload). After hitting submit you'll note that the window alerts you to the data that was sent to the Mephisto backend. @@ -45,7 +45,7 @@ To work on another task, you'll want to change the `assignment_id` in your url. If you try to work on another task, you'll note that the system states you've worked on the maximum number of tasks. On this task, this is because Mephisto has launched the same two tasks twice to attempt to get different workers to complete them, and as "x" you've already completed both tasks. More on this [later.](#unit-creation-explained) -If you change to another `worker_id`, however, you can complete two more tasks. Do this and the Mephisto process should shut down cleanly. +If you change to another `worker_id`, however, you can complete two more tasks. Do this and the Mephisto process should shut down cleanly. ### 1.3 Reviewing tasks @@ -60,7 +60,7 @@ For your convenience, for the `html-static-task-example` task we've already prov $ python examine_results.py Do you want to (r)eview, or (e)xamine data? Default examine. Can put e or e to choose how many to view >> r -Input task name: +Input task name: ``` Here we can enter the default task name for this task, `html-static-task-example` to see the results. You can also leave the two qualifications blank, as we aren't dealing with these yet. @@ -68,16 +68,16 @@ Here we can enter the default task name for this task, `html-static-task-example ``` Input task name: html-static-task-example If you'd like to soft-block workers, you'll need a block qualification. Leave blank otherwise. -Enter block qualification: +Enter block qualification: If you'd like to qualify high-quality workers, you'll need an approve qualification. Leave blank otherwise. -Enter approve qualification: +Enter approve qualification: Starting review with following params: Task name: html-static-task-example Blocking qualification: None Approve qualification: None -Press enter to continue... +Press enter to continue... ``` -After pressing enter, you'll be able to take action on some of the incoming tasks. You can `(a)ccept, (r)eject, (p)ass` using `a`, `r`, or `p`, using the caps version to apply to all the `Unit`s for a specific worker. Passing is used for work you think was attempted legitimately, but may have not been done +After pressing enter, you'll be able to take action on some of the incoming tasks. You can `(a)ccept, (r)eject, (p)ass` using `a`, `r`, or `p`, using the caps version to apply to all the `Unit`s for a specific worker. Passing is used for work you think was attempted legitimately, but may have not been done ``` Reviewing for worker x, (1/2), Previous (First time worker!) (total remaining: 4) ------------------- @@ -105,7 +105,7 @@ Mephisto configuration options can be inherited from a number of different locat ```bash $ mephisto wut architect=local - Architect Arguments + Architect Arguments ╭────────────────────┬──────┬───────────┬──────────────────────────────┬─────────┬──────────╮ │ dest │ type │ default │ help │ choices │ required │ ├────────────────────┼──────┼───────────┼──────────────────────────────┼─────────┼──────────┤ @@ -127,10 +127,10 @@ $ mephisto wut architect=local **For the blueprint:** ```bash $ mephisto wut blueprint=static_task -Tasks launched from static blueprints need a source html file to display to workers, -as well as a csv containing values that will be inserted into templates in the html. +Tasks launched from static blueprints need a source html file to display to workers, +as well as a csv containing values that will be inserted into templates in the html. - Blueprint Arguments + Blueprint Arguments ╭───────────────────┬─────────┬────────────────────┬───────────────────┬─────────┬──────────╮ │ dest │ type │ default │ help │ choices │ required │ ├───────────────────┼─────────┼────────────────────┼───────────────────┼─────────┼──────────┤ @@ -199,7 +199,7 @@ For our given example task, the values we are using for these options are availa As a simple starting point, we can try launching the server on a different port. Right now the default is `3000`, but with the following command we can set that ourselves: ``` -python static_test_script.py mephisto.architect.port=1234 +python run_task.py mephisto.architect.port=1234 ``` This should launch the same task, but now available on the port `1234` rather than `3000`. @@ -237,7 +237,7 @@ mephisto: Save this configuration file, and you're ready to launch again: ```bash -$ python static_test_script.py conf=my_config +$ python run_task.py conf=my_config ``` You'll note that Mephisto launches the task under your new task name: ``` @@ -282,7 +282,7 @@ mephisto: ``` Save this configuration file, and you're ready to see your task live: ```bash -$ python static_test_script.py conf=my_config +$ python run_task.py conf=my_config ``` Mephisto should print out a link to view your task on the mturk sandbox, like `https://workersandbox.mturk.com/mturk/preview?groupId=XXXXXXXXXXXXXXXX`. Navigate here and you're working on the same task, available on MTurk (on the sandbox at least)! @@ -292,13 +292,13 @@ Complete this task, and you can review it in the same way as before. ## 3. Task breakdown -Now that you've gotten a task running, this section gives a quick overview on some of the components in the configs and `static_test_script.py` that led to the observed behaviors. The goal is to ensure you can write your own run files by the end of the tutorial sections. +Now that you've gotten a task running, this section gives a quick overview on some of the components in the configs and `run_task.py` that led to the observed behaviors. The goal is to ensure you can write your own run files by the end of the tutorial sections. ### 3.1 Config registration -Mephisto wires up to configuration using standard Hydra syntax, but with both `yaml` files (for ease of writing) _and_ structured configs (for ease of documentation). +Mephisto wires up to configuration using standard Hydra syntax, but with both `yaml` files (for ease of writing) _and_ structured configs (for ease of documentation). Here's the config we've set up for this example: ```python -# static_test_script.py +# run_task.py from mephisto.abstractions.blueprints.static_html_task.static_html_blueprint import ( BLUEPRINT_TYPE_STATIC_HTML, ) @@ -312,7 +312,7 @@ This is all you really *need* to launch a Mephisto task! The `@task_script` deco Of course, there's quite a bit of 'magic' happening underneath the hood thanks to the script utilities. This version is explicit to show where you may add customization, and re-ordered for understanding: ```python -# modified static_test_script.py +# modified run_task.py from mephisto.abstractions.blueprints.static_html_task.static_html_blueprint import ( BLUEPRINT_TYPE_STATIC_HTML, ) diff --git a/examples/simple_static_task/README.md b/examples/simple_static_task/README.md index 675138ac4..ae12bea9e 100644 --- a/examples/simple_static_task/README.md +++ b/examples/simple_static_task/README.md @@ -15,11 +15,11 @@ python run_task.py and can additionally be launched with an onboarding step by specifying an onboarding qualification: ```console -python static_run_with_onboarding.py +python run_task_with_onboarding.py ``` ## Submit button customization -### Hide the submit button +### Hide the submit button Writing the markup below in `demo_task.html` will allow you to hide the submit button. ```html @@ -44,10 +44,10 @@ python run_task.py ``` This will run the task. -Then go into the `mephisto/abstractions/blueprints/static_html_task/source` and run +Then go into the `mephisto/abstractions/blueprints/static_html_task/source` and run ```console npm run test -``` +``` to open cypress. Select the Chrome browser and click on the one spec that shows up to run the tests. diff --git a/examples/simple_static_task/run_task_ec2_prolific.py b/examples/simple_static_task/run_task_ec2_prolific.py index 6a2c3e79b..538d37484 100644 --- a/examples/simple_static_task/run_task_ec2_prolific.py +++ b/examples/simple_static_task/run_task_ec2_prolific.py @@ -20,7 +20,7 @@ def main(operator, cfg: DictConfig) -> None: # Mephisto qualifications shared_state.qualifications = [ - make_qualification_dict('sample_qual_name', QUAL_GREATER_EQUAL, 1), + make_qualification_dict("sample_qual_name", QUAL_GREATER_EQUAL, 1), ] # Prolific qualifications diff --git a/mephisto/abstractions/providers/prolific/README.md b/mephisto/abstractions/providers/prolific/README.md index 0c090a16e..b82cbfccc 100644 --- a/mephisto/abstractions/providers/prolific/README.md +++ b/mephisto/abstractions/providers/prolific/README.md @@ -30,14 +30,14 @@ Shared state handles both custom and Prolific-supported qualifications: ```python shared_state.prolific_specific_qualifications = [ { - 'name': 'AgeRangeEligibilityRequirement', - 'min_age': 18, - 'max_age': 100, + "name": "AgeRangeEligibilityRequirement", + "min_age": 18, + "max_age": 100, }, ] shared_state.qualifications = [ - make_qualification_dict('sample_qual_name', QUAL_GREATER_EQUAL, 1), + make_qualification_dict("sample_qual_name", QUAL_GREATER_EQUAL, 1), ] ``` @@ -48,7 +48,7 @@ under the key `prolific_eligibility_requirements` like so: mephisto: provider: prolific_eligibility_requirements: - - name: 'AgeRangeEligibilityRequirement' + - name: "AgeRangeEligibilityRequirement" min_age: 10 max_age: 20 ``` @@ -63,35 +63,35 @@ List of supported Eligibility Requirements for `SharedState.prolific_specific_qu ```python [ { - 'name': 'AgeRangeEligibilityRequirement', - 'min_age': '', - 'max_age': '', + "name": "AgeRangeEligibilityRequirement", + "min_age": "", + "max_age": "", }, { - 'name': 'ApprovalNumbersEligibilityRequirement', - 'minimum_approvals': '', - 'maximum_approvals': '', + "name": "ApprovalNumbersEligibilityRequirement", + "minimum_approvals": "", + "maximum_approvals": "", }, { - 'name': 'ApprovalRateEligibilityRequirement', - 'minimum_approval_rate': '', - 'maximum_approval_rate': '', + "name": "ApprovalRateEligibilityRequirement", + "minimum_approval_rate": "", + "maximum_approval_rate": "", }, { - 'name': 'CustomBlacklistEligibilityRequirement', - 'black_list': '', + "name": "CustomBlacklistEligibilityRequirement", + "black_list": "", }, { - 'name': 'CustomWhitelistEligibilityRequirement', - 'white_list': '', + "name": "CustomWhitelistEligibilityRequirement", + "white_list": "", }, { - 'name': 'JoinedBeforeEligibilityRequirement', - 'joined_before': '', + "name": "JoinedBeforeEligibilityRequirement", + "joined_before": "", }, { - 'name': 'ParticipantGroupEligibilityRequirement', - 'id': '', + "name": "ParticipantGroupEligibilityRequirement", + "id": "", }, ] ``` diff --git a/mephisto/client/review_app/client/src/pages/TaskPage/ModalForm/ModalForm.tsx b/mephisto/client/review_app/client/src/pages/TaskPage/ModalForm/ModalForm.tsx index 5da4b129c..a8601fbea 100644 --- a/mephisto/client/review_app/client/src/pages/TaskPage/ModalForm/ModalForm.tsx +++ b/mephisto/client/review_app/client/src/pages/TaskPage/ModalForm/ModalForm.tsx @@ -300,38 +300,39 @@ function ModalForm(props: ModalFormProps) {
- {BONUS_FOR_WORKER_ENABLED && props.data.form.checkboxGiveBonus !== undefined && ( - <> - - onChangeGiveBonus(!props.data.form.checkboxGiveBonus) - } - /> - - {props.data.form.checkboxGiveBonus && ( - - - onChangeBonus(e.target.value)} - /> - - - Amount (cents) - - - )} + {BONUS_FOR_WORKER_ENABLED && + props.data.form.checkboxGiveBonus !== undefined && ( + <> + + onChangeGiveBonus(!props.data.form.checkboxGiveBonus) + } + /> + + {props.data.form.checkboxGiveBonus && ( + + + onChangeBonus(e.target.value)} + /> + + + Amount (cents) + + + )} -
- - )} +
+ + )} {props.data.form.checkboxBanWorker !== undefined && ( <> @@ -351,7 +352,9 @@ function ModalForm(props: ModalFormProps) { @@ -380,7 +383,9 @@ function ModalForm(props: ModalFormProps) { id={"reviewNoteSend"} checked={props.data.form.checkboxReviewNoteSend} onChange={() => - onChangeWriteReviewNoteSend(!props.data.form.checkboxReviewNoteSend) + onChangeWriteReviewNoteSend( + !props.data.form.checkboxReviewNoteSend + ) } /> diff --git a/mephisto/client/review_app/client/src/pages/TasksPage/TasksPage.tsx b/mephisto/client/review_app/client/src/pages/TasksPage/TasksPage.tsx index ec08e7297..84c7d3bd5 100644 --- a/mephisto/client/review_app/client/src/pages/TasksPage/TasksPage.tsx +++ b/mephisto/client/review_app/client/src/pages/TasksPage/TasksPage.tsx @@ -57,7 +57,12 @@ function TasksPage(props: PropsType) { } }; - exportTaskResults(taskId, onSuccessExportResults, setLoadingExportResults, onError); + exportTaskResults( + taskId, + onSuccessExportResults, + setLoadingExportResults, + onError + ); }; useEffect(() => { diff --git a/poetry.lock b/poetry.lock index 4433adc93..afbfd9313 100644 --- a/poetry.lock +++ b/poetry.lock @@ -797,6 +797,20 @@ dev = ["coverage", "pallets-sphinx-themes", "pytest", "sphinx", "sphinx-issues", docs = ["pallets-sphinx-themes", "sphinx", "sphinx-issues", "sphinxcontrib-log-cabinet"] dotenv = ["python-dotenv"] +[[package]] +name = "flask-cors" +version = "4.0.0" +description = "A Flask extension adding a decorator for CORS support" +optional = false +python-versions = "*" +files = [ + {file = "Flask-Cors-4.0.0.tar.gz", hash = "sha256:f268522fcb2f73e2ecdde1ef45e2fd5c71cc48fe03cffb4b441c6d1b40684eb0"}, + {file = "Flask_Cors-4.0.0-py2.py3-none-any.whl", hash = "sha256:bc3492bfd6368d27cfe79c7821df5a8a319e1a6d5eab277a3794be19bdc51783"}, +] + +[package.dependencies] +Flask = ">=0.9" + [[package]] name = "frozenlist" version = "1.3.1" diff --git a/scripts/update_copyright_headers.py b/scripts/update_copyright_headers.py index cf96ffac4..b5887fbb4 100644 --- a/scripts/update_copyright_headers.py +++ b/scripts/update_copyright_headers.py @@ -134,14 +134,14 @@ def _update_copyright_header(file_path: str, replace_existing: bool = False): if is_empty_line(i): if i < anchor_line_number: # Move up lower notice boundary only if previous line is not comment opening - if line_has_words(i-1): + if line_has_words(i - 1): first_line_number = i + 1 else: last_line_number = i - 1 # Set upper notice boundary only except cases when # next line is a comment closing line followed by an empty line # (Note: this fails if old copyright notice has line breaks in it) - if not (not line_has_words(i+1) and is_empty_line(i+2)): + if not (not line_has_words(i + 1) and is_empty_line(i + 2)): break if last_line_number is None: diff --git a/test/review_app/server/api/base_test_api_view_case.py b/test/review_app/server/api/base_test_api_view_case.py index e1cbb65da..ccba24639 100644 --- a/test/review_app/server/api/base_test_api_view_case.py +++ b/test/review_app/server/api/base_test_api_view_case.py @@ -44,5 +44,5 @@ def tearDown(self): self.db.shutdown() shutil.rmtree(self.data_dir, ignore_errors=True) - # Clean Falsk app context + # Clean Flask app context self.app_context.pop()