Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prolific provider (#1008) #1012

Merged
merged 53 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
df0f514
WIP initial commit - main models, base API resource, base exceptions
meta-paul Mar 13, 2023
383da82
Added API resources and data models
meta-paul Mar 16, 2023
87b37a3
Added remaining API resources, moved SDK into 'abstractions' folder, …
meta-paul Mar 27, 2023
7aa9fda
Added task params, docker-compose execution, updated config
meta-paul Apr 11, 2023
1574c70
Added simple eligibility criteria, moved args from task_run to provider
meta-paul May 4, 2023
beffb95
Modified Participant Groups and Worker
meta-paul May 11, 2023
749b017
Added worker logic and worker bonus
meta-paul May 17, 2023
8429c44
Added worksspace balance API, fixed types
meta-paul May 22, 2023
d834ced
Added payment calculation for assignments, fixed tests
meta-paul May 25, 2023
082d778
Adjusted launching of Study, data store refactoring
meta-paul May 25, 2023
9c2b514
modified ProlificAgent and ProlificWorker
meta-paul May 31, 2023
bc34b57
Added preliminary status code, updated wrap_crowd_source.js
meta-paul Jun 1, 2023
2718655
Fixed age eligibility request, external_study_url, submissions saving…
meta-paul Jun 8, 2023
c984246
Fixed errors during task launch
meta-paul Jun 10, 2023
b734e8d
fixed register_run in Datastore
meta-paul Jun 14, 2023
49d86cc
fixed saving task results
meta-paul Jun 14, 2023
17ede4d
Added log coverage, light refactoring
meta-paul Jun 15, 2023
3aaa878
Fixed launching task unit for a study
meta-paul Jun 16, 2023
ac741cc
Updated assignment status mapping
meta-paul Jun 16, 2023
ac594c8
Fixing task submissions
meta-paul Jun 22, 2023
50faed5
Fixed submission approval
meta-paul Jun 23, 2023
b619d9f
Hack to circumvent EC2 connection error
meta-paul Jun 26, 2023
d6d90da
Fixed approval of Submissions
meta-paul Jun 26, 2023
a2bc750
Added study expiration
meta-paul Jun 27, 2023
328403c
Moved creation of Study out of Unit.launch
meta-paul Jun 28, 2023
58fc94b
Fixed multiple participant studies, added EC2 cleanup script
meta-paul Jun 29, 2023
2a0dba3
Fixed deleting participants from group
meta-paul Jul 5, 2023
1e8e276
Fixed submissions for multiple participant studies
meta-paul Jul 5, 2023
a386277
Adding auth implementation of prolific client
JackUrb Jul 7, 2023
60990e0
Merge pull request #1028 from facebookresearch/prolific-auth-client
JackUrb Jul 10, 2023
dbd5b14
Added task review option (undocumented)
meta-paul Jul 10, 2023
88ac0e9
Added ingestion of prolific-specific qualifications, using SharedState
meta-paul Jul 11, 2023
3d13138
Debugged granting qualifications during unit launch
meta-paul Jul 12, 2023
aea4e5c
Added handling of empty eligibility requirements
meta-paul Jul 13, 2023
242cca6
Added logic for grant_crowd_qualification and block_worker
meta-paul Jul 14, 2023
daf748a
Added incomplete studies filter to crowd qualifications
meta-paul Jul 18, 2023
b8d8b85
Bugfixes with qualifications and approvals
meta-paul Jul 18, 2023
dd7a66d
Workaround for retrieving Prolific groups
meta-paul Jul 19, 2023
be873d3
Updated server cleanup script
meta-paul Jul 24, 2023
5114a06
Fixes following code review
meta-paul Jul 25, 2023
03ab8fa
Small fixes
meta-paul Jul 25, 2023
f6a28a4
merged code from main branch
meta-paul Jul 25, 2023
e31e516
Merge branch 'main' into add-prolific-provider
meta-paul Jul 25, 2023
b207500
removed a connection timeout hack
meta-paul Jul 25, 2023
19a2354
Fixed edge case with unclaimed units
meta-paul Jul 27, 2023
50514ba
Updated example launch files
meta-paul Jul 27, 2023
1807386
Added logic to auto-increment available places on Prolific
meta-paul Aug 1, 2023
a971702
Debugged with max_num_concurrent_units=1
meta-paul Aug 2, 2023
78ff3f5
Changed logic of Unit status to be based on Submission, not Study
meta-paul Aug 3, 2023
5dc9c47
Fixed expired study status check
meta-paul Aug 3, 2023
db3dd84
Refactored ProlificUnit.get_status
meta-paul Aug 4, 2023
7d08666
Temporarily removing prolific from testing
JackUrb Aug 4, 2023
c66b861
Merge branch 'add-prolific-provider' of https://github.com/facebookre…
JackUrb Aug 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mephisto.egg-info/*
tmp/*
**/node_modules/*
mephisto/server/**/package-lock.json
mephisto/abstractions/**/package-lock.json
mephisto/server/blueprints/**/build/*

**/*.log
Expand All @@ -25,12 +26,15 @@ mephisto/scripts/metrics/*
# Examples
examples/simple_static_task/hydra_configs/conf/*
!examples/simple_static_task/hydra_configs/conf/example.yaml
!examples/simple_static_task/hydra_configs/conf/prolific_example.yaml
!examples/simple_static_task/hydra_configs/conf/onboarding_example.yaml
examples/**/build/*

# PyCharm
.idea

# VSCode
.vscode

# https://next.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
Expand All @@ -42,4 +46,12 @@ examples/**/build/*
!.yarn/versions
.pnp.*

docs/storybook/storybook-static/*
docs/storybook/storybook-static/*

# local deploy
hydra_configs/profile/*.yaml
!hydra_configs/profile/local_dev.yaml
aws_credentials
docker-compose.local.*
env.local
my-review-interface
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"typescript.tsdk": "mephisto/mephisto/webapp/node_modules/typescript/lib",
"python.linting.pylintEnabled": false,
"python.linting.mypyEnabled": true,
"python.linting.enabled": true
"python.linting.mypyEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ ARG BASE_IMAGE=nikolaik/python-nodejs:$BASE_TAG

FROM $BASE_IMAGE

# ec2 architect requires `ssh-keygen` util, so we need to install it.
# Firstly, remove `yarn` repo as it causes error that stops building a container. Error:
# (Error: The repository 'https://dl.yarnpkg.com/debian stable InRelease' is not signed)
RUN rm /etc/apt/sources.list.d/yarn.list
RUN apt update
RUN apt install keychain -y

COPY . /mephisto
RUN mkdir ~/.mephisto

Expand Down
7 changes: 7 additions & 0 deletions docker/aws_credentials.example
JackUrb marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ec2-profile-name]
aws_access_key_id=XXXXXXXXX
aws_secret_access_key=XXXXXXXXX

[MTurk-profile-name]
aws_access_key_id=XXXXXXXXX
aws_secret_access_key=XXXXXXXXX
31 changes: 31 additions & 0 deletions docker/docker-compose.dev.vscode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'

services:
fb_mephisto_vscode:
container_name: fb_mephisto_vscode
build:
context: ..
dockerfile: Dockerfile
ports:
- '8081:8000'
- '3001:3000'
- '5678:5678'
volumes:
- ..:/mephisto
- ./entrypoints/server.sh:/entrypoint.sh
- ./aws_credentials:/root/.aws/credentials
- ./ssh_known_hosts:/root/.ssh/known_hosts
entrypoint: /entrypoint.sh
env_file: envs/env.local
command: [
"sh",
"-c",
"pip install debugpy -t /tmp
&&
python
/tmp/debugpy
--wait-for-client
--listen 0.0.0.0:5678
/mephisto/examples/simple_static_task/static_test_script.py
"
]
20 changes: 20 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

services:
fb_mephisto:
container_name: fb_mephisto
build:
context: ..
dockerfile: Dockerfile
ports:
- '8081:8000'
- '3001:3000'
volumes:
- ..:/mephisto
- ./entrypoints/server.prolific.sh:/entrypoint.sh
- ./aws_credentials:/root/.aws/credentials
- ./ssh_known_hosts:/root/.ssh/known_hosts
entrypoint: /entrypoint.sh
env_file: envs/env.dev
command: tail -f /dev/null

13 changes: 13 additions & 0 deletions docker/entrypoints/server.mturk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e

pip install pytest
cd /mephisto
mkdir -p "data" && chmod 777 "data"

mephisto register mturk_sandbox \
name=$MTURK_SANDBOX_NAME \
access_key_id=$MTURK_SANDBOX_ACCESS_KEY_ID \
secret_access_key=$MTURK_SANDBOX_SECRET_ACCESS_KEY

exec "$@"
10 changes: 10 additions & 0 deletions docker/entrypoints/server.prolific.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -e

pip install pytest black
cd /mephisto
mkdir -p "data" && chmod 777 "data"

mephisto register prolific name=prolific api_key=$PROLIFIC_API_KEY

exec "$@"
1 change: 1 addition & 0 deletions docker/envs/env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROLIFIC_API_KEY="dev"
Empty file added docker/ssh_known_hosts
Empty file.
2 changes: 2 additions & 0 deletions examples/simple_static_task/data_prolific.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
character_name,character_description
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason to have a separate data file for Prolific?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to have 1 study per paunch :) No problem, I'll remove it when code testing is finished

Loaded Character 1,I'm a Prolific character loaded from Mephisto!
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#@package _global_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, eventually we'll move this to an example provider config and put it in a guide - it probably won't remain a standard part of the simple_static_task especially given external folks aren't definitely using the ec2 setup.

defaults:
- /mephisto/blueprint: static_task
- /mephisto/architect: ec2
- /mephisto/provider: prolific
mephisto:
architect:
_architect_type: ec2
profile_name: mephisto-router-iam
subdomain: '0623.1'
blueprint:
data_csv: ${task_dir}/data_prolific.csv
task_source: ${task_dir}/server_files/demo_task.html
preview_source: ${task_dir}/server_files/demo_preview.html
extra_source_dir: ${task_dir}/server_files/extra_refs
units_per_assignment: 1
log_level: 'debug'
task:
task_name: '0623'
task_title: '0623 Task'
task_description: 'This is a simple test of static Prolific tasks.'
task_reward: 70
task_tags: 'static,task,testing'
provider:
prolific_external_study_url: 'https://example.com?participant_id={{%PROLIFIC_PID%}}&study_id={{%STUDY_ID%}}&submission_id={{%SESSION_ID%}}'
prolific_id_option: 'url_parameters'
prolific_workspace_name: 'My Workspace'
prolific_project_name: 'Project'
prolific_allow_list_group_name: 'Allow list'
prolific_block_list_group_name: 'Block list'
prolific_total_available_places: 1
prolific_eligibility_requirements:
- name: 'CustomWhitelistEligibilityRequirement'
white_list:
- '6463d16eb92a24a0c3fdc8d5'
# - '6463d32f50a18041930b71be'
# - '6463d3922d7d99360896228f'
# - name: 'AgeRangeEligibilityRequirement'
# min_age: 10
# max_age: 20
# - name: 'ApprovalNumbersEligibilityRequirement'
# minimum_approvals: 100
# maximum_approvals: 200
# - name: 'ApprovalRateEligibilityRequirement'
# minimum_approval_rate: 10
# maximum_approval_rate: 20
# - name: 'JoinedBeforeEligibilityRequirement'
# joined_before: ''
42 changes: 42 additions & 0 deletions examples/simple_static_task/static_test_prolific_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this is all functional, I'm not sure what the correct thing for us to be doing to demonstrate different providers will be, but I don't think it's going to be to have a different script in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there are some Prolific-specific bits in there, like default_config_file and shared_state.prolific_specific_qualifications (it was meant to show how to work with Prolific-specific integration)

Copy link
Contributor

@JackUrb JackUrb Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, just I think we need to have another way to demonstrate provider use in a script, rather than leaving them in task examples (something like examples/providers which uses a simple task (ideally the React variant) and show it for multiple providers). We can commit here for now, but it's a TODO item.


# Copyright (c) Facebook, Inc. 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.abstractions.blueprints.abstract.static_task.static_blueprint import (
SharedStaticTaskState,
)
from mephisto.data_model.qualification import QUAL_GREATER_EQUAL
from mephisto.tools.scripts import task_script
from mephisto.utils.qualifications import make_qualification_dict


@task_script(default_config_file='prolific_example')
def main(operator, cfg: DictConfig) -> None:
shared_state = SharedStaticTaskState()

# Mephisto qualifications
shared_state.qualifications = [
make_qualification_dict('ok', QUAL_GREATER_EQUAL, 1),
]

# Prolific qualifications
# shared_state.prolific_specific_qualifications = [
# {
# # Without `web.eligibility.models.` as API requires. We will add it in the code
# 'name': 'AgeRangeEligibilityRequirement',
# # Prolific Eligibility Requirement attributes and its values
# 'min_age': 20,
# 'max_age': 100,
# },
# ]

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


if __name__ == '__main__':
main()
3 changes: 0 additions & 3 deletions examples/simple_static_task/static_test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from mephisto.abstractions.blueprints.static_html_task.static_html_blueprint import (
BLUEPRINT_TYPE_STATIC_HTML,
)
Comment on lines -7 to -9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as this appears an unnecessary import, the forced load of a Blueprint's module ensures that Mephisto is able to use that task. While we pre-load all of the Mephisto-standard blueprints, I've left this here to pre-empt the question when externally implemented blueprints aren't functioning for others.

I definitely think there's room to improve the way the Mephisto registry works such that it isn't hinging on the side-effects of an import.

from mephisto.tools.scripts import task_script
from omegaconf import DictConfig

Expand Down
Loading