Skip to content

Commit

Permalink
Added task params, docker-compose execution, updated config
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Apr 11, 2023
1 parent 87b37a3 commit 08aa5c3
Show file tree
Hide file tree
Showing 20 changed files with 26,339 additions and 53 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ examples/**/build/*
# PyCharm
.idea

# VSCode
.vscode

# https://next.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
Expand All @@ -42,4 +44,11 @@ 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
# docker/*
aws_credentials
env.local
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mephisto-router-iam]
aws_access_key_id=XXXXXXXXX
aws_secret_access_key=XXXXXXXXX

[NoahTurk1027]
aws_access_key_id=XXXXXXXXX
aws_secret_access_key=XXXXXXXXX
31 changes: 31 additions & 0 deletions docker/docker-compose.local.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.local.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.sh:/entrypoint.sh
- ./aws_credentials:/root/.aws/credentials
- ./ssh_known_hosts:/root/.ssh/known_hosts
entrypoint: /entrypoint.sh
env_file: envs/env.local
command: tail -f /dev/null

13 changes: 13 additions & 0 deletions docker/entrypoints/server.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=NoahTurk1027 \
access_key_id=$MTURK_SANDBOX_ACCESS_KEY_ID__NOAH \
secret_access_key=$MTURK_SANDBOX_SECRET_ACCESS_KEY__NOAH

exec "$@"
Empty file added docker/ssh_known_hosts
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ mephisto:
task_tags: "static,task,testing"
# We expect to be able to handle 300 concurrent tasks without issue
max_num_concurrent_units: 300
test: 777
12 changes: 11 additions & 1 deletion examples/simple_static_task/static_test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from dataclasses import dataclass
from dataclasses import field
from mephisto.abstractions.blueprints.static_html_task.static_html_blueprint import (
BLUEPRINT_TYPE_STATIC_HTML,
)
from mephisto.data_model.task_run import TaskRunArgs
from mephisto.tools.scripts import task_script
from omegaconf import DictConfig


@task_script(default_config_file="example")
@dataclass
class TaskRunArgs2(TaskRunArgs):
test: int = field(
default=500,
)


@task_script(default_config_file="example", task_run_args_cls=TaskRunArgs2)
def main(operator, cfg: DictConfig) -> None:
operator.launch_task_run(cfg.mephisto)
operator.wait_for_runs_then_shutdown(skip_input=True, log_rate=30)
Expand Down
Loading

0 comments on commit 08aa5c3

Please sign in to comment.