Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[Pending Release] Updating to Mephisto 0.4.0 #3982

Merged
merged 7 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ commands:
command: |
cd ..
git clone [email protected]:facebookresearch/Mephisto.git Mephisto
cd Mephisto; git checkout v0.3.4 -b stable
cd Mephisto; git checkout v0.4.0 -b stable
pip install -r requirements.txt
python setup.py develop
# `echo` so that ENTER will be pressed at the prompt
Expand Down
4 changes: 2 additions & 2 deletions parlai/crowdsourcing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Code for crowdsourcing tasks that use Mephisto. See the [Mephisto quick start gu

## Running tasks

Tasks are launched by calling the appropriate run script: for instance, an ACUTE-Eval run can be launched with `python parlai/crowdsourcing/tasks/acute_eval/run.py`, followed by any appropriate flags. All run parameters are set using [Hydra](https://github.com/facebookresearch/hydra): append the flag `-c job` to your run command to see a list of all available parameters, grouped by their package name (`mephisto.blueprint`, `mephisto.task`, etc.), which determines how they are called. Each run script has a YAML file of default parameters that will be loaded, found in the `conf/` subfolder of each task.
Tasks are launched by calling the appropriate run script: for instance, an ACUTE-Eval run can be launched with `python parlai/crowdsourcing/tasks/acute_eval/run.py`, followed by any appropriate flags. All run parameters are set using [Hydra](https://github.com/facebookresearch/hydra): append the flag `-c job` to your run command to see a list of all available parameters, grouped by their package name (`mephisto.blueprint`, `mephisto.task`, etc.), which determines how they are called. Each run script has a YAML file of default parameters that will be loaded, found in the `hydra_configs/conf/` subfolder of each task.

### Specifying your own YAML file

The easiest way to specify a different YAML file is to create a new file, say, `my_params.yaml`, in the `conf/` subfolder of the task. Then, you can launch HITs with `python ${TASK_FOLDER}/run.py conf=my_params`.
The easiest way to specify a different YAML file is to create a new file, say, `my_params.yaml`, in the `hydra_configs/conf/` subfolder of the task. Then, you can launch HITs with `python ${TASK_FOLDER}/run.py conf=my_params`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the change :) The conf/ mention on line 9 should also be changed to hydra_configs/conf/, right?


You also can specify a path to a YAML file existing *outside* of `${TASK_FOLDER}`: you will need to have your YAML file stored at a location `${CUSTOM_FOLDER}/conf/my_params.yaml`, and then you can add a `--config-dir ${CUSTOM_FOLDER}` string to the launch command above.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
check_override_opt(cfg.mephisto)
run_task(cfg=cfg, task_directory=TASK_DIRECTORY, world_module=None)
Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/projects/wizard_of_internet/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def add_banned_words_frontend_conf(task_state, fpath: str = None):
task_state.task_config['bannedWords'] = banned_words


@hydra.main(config_name='scriptconfig')
@hydra.main(config_path="hydra_configs", config_name='scriptconfig')
def main(cfg: DictConfig) -> None:
db, cfg = load_db_and_process_config(cfg)
world_opt = get_world_opt(cfg)
Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/acute_eval/fast_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class TestScriptConfig(MTurkRunScriptConfig):
register_script_config(name='fast_acute_scriptconfig', module=TestScriptConfig)


@hydra.main(config_name="fast_acute_scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="fast_acute_scriptconfig")
def main(cfg: DictConfig) -> None:

runner = FastAcuteExecutor(cfg)
Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/acute_eval/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
db, cfg = load_db_and_process_config(cfg)
print(f'*** RUN ID: {cfg.mephisto.task.task_name} ***')
Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/model_chat/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
run_task(cfg=cfg, task_directory=TASK_DIRECTORY, world_module=world_module)

Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/model_chat/run_image_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
run_task(cfg=cfg, task_directory=TASK_DIRECTORY, world_module=world_module)

Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/qa_data_collection/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name="scriptconfig", module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
db, cfg = load_db_and_process_config(cfg)

Expand Down
2 changes: 1 addition & 1 deletion parlai/crowdsourcing/tasks/turn_annotations_static/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
run_static_task(cfg=cfg, task_directory=TASK_DIRECTORY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
run_static_task(cfg=cfg, task_directory=TASK_DIRECTORY)

Expand Down
5 changes: 4 additions & 1 deletion parlai/crowdsourcing/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ def _set_up_config(
relative_task_directory = os.path.relpath(
task_directory, os.path.dirname(__file__)
)
relative_config_path = os.path.join(relative_task_directory, 'conf')
relative_config_path = os.path.join(
relative_task_directory, 'hydra_configs', 'conf'
)
if overrides is None:
overrides = []
with initialize(config_path=relative_config_path):
self.config = compose(
config_name="example",
overrides=[
f'+mephisto.blueprint._blueprint_type={blueprint_type}',
f'+mephisto.blueprint.link_task_source=False',
f'+mephisto/architect=mock',
f'+mephisto/provider=mock',
f'+task_dir={task_directory}',
Expand Down
2 changes: 1 addition & 1 deletion projects/safety_recipes/human_safety_evaluation/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ScriptConfig(MTurkRunScriptConfig):
register_script_config(name='scriptconfig', module=ScriptConfig)


@hydra.main(config_name="scriptconfig")
@hydra.main(config_path="hydra_configs", config_name="scriptconfig")
def main(cfg: DictConfig) -> None:
run_static_task(cfg=cfg, task_directory=BASE_TASK_DIRECTORY)

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ flake8==3.7.8
iopath~=0.1.8
gitdb2==2.0.5
GitPython==3.0.3
hydra-core~=1.0.6
hydra-core~=1.1.0
ipython==7.19.0
torch>=1.4.0
joblib==0.14.1
nltk==3.4.5
numpy==1.17.5
omegaconf<2.1.0
omegaconf~=2.1.1
pandas==1.1.1
pytest_regressions==2.1.1
pytest==5.3.2
Expand Down