Skip to content

Commit

Permalink
Merge pull request #1207 from facebookresearch/fix-grafana-launch
Browse files Browse the repository at this point in the history
Update Grafana dockerized deployment and docs, refactor CLI commands
  • Loading branch information
meta-paul authored Jul 5, 2024
2 parents 6f92517 + 8565fcd commit 5e7eb18
Show file tree
Hide file tree
Showing 33 changed files with 1,296 additions and 581 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM $BASE_IMAGE
# 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 apt update
RUN apt install keychain -y
RUN apt install keychain curl -y

COPY . /mephisto
RUN mkdir ~/.mephisto
Expand Down
7 changes: 4 additions & 3 deletions docker/docker-compose.dev.vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ services:
context: ..
dockerfile: Dockerfile
ports:
- "8081:8000"
- "3001:3000"
- "5678:5678"
- "8081:8000" # TaskReview app
- "3001:3000" # Task app
- "3032:3032" # Grafana metrics
- "5678:5678" # VSCode Python debugger
volumes:
- ..:/mephisto
- ./entrypoints/server.sh:/entrypoint.sh
Expand Down
5 changes: 3 additions & 2 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ services:
context: ..
dockerfile: Dockerfile
ports:
- "8081:8000"
- "3001:3000"
- "8081:8000" # TaskReview app
- "3001:3000" # Task app
- "3032:3032" # Grafana metrics
volumes:
- ..:/mephisto
- ./entrypoints/server.prolific.sh:/entrypoint.sh
Expand Down
7 changes: 7 additions & 0 deletions docker/envs/env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ AWS_SECRET_ACCESS_KEY=your_key
AWS_DEFAULT_REGION=us-east-1
S3_URL_EXPIRATION_MINUTES=60

# Cypress
CYPRESS_CACHE_FOLDER=/tmp

# Grafana
GRAFANA_HOST=localhost
GRAFANA_PORT=3032
GRAFANA_USER=admin
GRAFANA_PASSWORD=admin
7 changes: 4 additions & 3 deletions docs/web/docs/explanations/architecture_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
sidebar_position: 1
---

# Architecture diagram
## Architecture diagram

At a high level, Mephisto runs its data collection/annotation tasks as shown in this sequence diagram.

!`task_run_sequence_diagram.png`(./images/task_run_sequence_diagram.png)
![task_run_sequence_diagram.png](./images/task_run_sequence_diagram.png)

# Codebase structure

## Codebase structure

This is a quick guide over file directories in Mephisto project. Note that some directories include their own `README.md` file with further details.

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@ Seem exciting? Let's dig in!
## Installation

Installation is easy, just run the setup script:
```
```shell
mephisto metrics install
```

This script creates a local `prometheus` and `grafana` folder in mephisto's `metrics` directory, and populates them with default configurations for being able to view Mephisto run metrics.

> NOTE: You may see a request to install `curl`.
> In some systems it may not be installed. Do this manually.
> Steps may be different depending on your system.
If you use Docker, you need to connect to its environment (applies to other metrics commands as well):
```shell
docker-compose -f docker/docker-compose.dev.yml up
docker exec -it mephisto_dc bash
mephisto metrics install
```

## Usage

Once you have metrics installed, all future runs will be logging metrics by default. You can view these metrics with:
Expand Down Expand Up @@ -101,3 +112,37 @@ For this section, each of the plots can show the health of your system in a numb
### Onboarding and Other Validation Metrics

Similarly to the above dashboards, these panels provide details about onboarding-specific or other validation-specific processes.

## Other commands

### Cleanup

If you need to shut down Prometheus and Grafana resources that may have persisted:
```shell
mephisto metrics cleanup
```

### Remove

If you do not need metrics after testing anymore, you can remove all files to save space:
```shell
mephisto metrics remove
```

### Reinstall

If you already had metrics installed, but they were updated in a newer Mephisto version, you can update them locally:
```shell
mephisto metrics reinstall
```

## Configuration

If you wish to customize host, port, user or password for Grafana, you can set the following environment variables:

- `GRAFANA_HOST` - Host of Grafana server (Default in Docker: `localhost`)
- `GRAFANA_PORT` - Port of Grafana server (Default in Docker: `3032`)
- `GRAFANA_USER` - Name of a user to login in web client (Default in Docker: `admin`)
- `GRAFANA_PASSWORD` - Password of a user to login in web client (Default in Docker: `admin`)

> NOTE: If you created Mephisto environment on your own, setting these variables is required.
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<mxfile host="app.diagrams.net" modified="2024-07-02T18:11:12.191Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" etag="v3RLzFtH0SjPhTHox-c7" version="24.6.4" type="device">
<diagram name="Page-1" id="5bnjxatqjOuaAF2oe5hL">
<mxGraphModel dx="954" dy="-458" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="5EaqwkNcLw-vjFIcxztH-12" value="&amp;nbsp; &amp;nbsp;[singe task unit review]" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=10;verticalAlign=top;align=left;fontColor=#007FFF;arcSize=7;opacity=40;fontStyle=2" vertex="1" parent="1">
<mxGeometry x="160" y="1467" width="420" height="123" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-63" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;strokeColor=#CCCCCC;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="380" y="1710" as="sourcePoint" />
<mxPoint x="380" y="1180" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-66" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;strokeColor=#CCCCCC;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="180" y="1610" as="sourcePoint" />
<mxPoint x="180.5" y="1180" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-67" value="TaskReview app" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="344" y="1130" width="70" height="40" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-70" value="Provider&lt;br style=&quot;font-size: 10px;&quot;&gt;API" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="145" y="1130" width="70" height="40" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-72" value="Mephisto DB" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="246" y="1130" width="70" height="40" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-73" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;strokeColor=#CCCCCC;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="280" y="1610" as="sourcePoint" />
<mxPoint x="280" y="1180" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-75" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1211" as="sourcePoint" />
<mxPoint x="380" y="1211" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-77" value="build and start&lt;br&gt;TaskReview app" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;glass=0;shadow=0;" parent="1" vertex="1">
<mxGeometry x="339" y="1231" width="82" height="30" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-83" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="379" y="1358" as="sourcePoint" />
<mxPoint x="280" y="1358" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-84" value="retrieve completed tasks" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="288" y="1335" width="88" height="17" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-113" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;strokeColor=#CCCCCC;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1710" as="sourcePoint" />
<mxPoint x="560" y="1181" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-114" value="Reviewer" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="525" y="1130" width="70" height="40" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-116" value="run command&lt;br&gt;`mephisto review app ...`&amp;nbsp;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="404" y="1181" width="138" height="27" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-117" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1320" as="sourcePoint" />
<mxPoint x="380" y="1320" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-118" value="open &quot;Tasks&quot; page" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="395" y="1303" width="138" height="13" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-119" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1420" as="sourcePoint" />
<mxPoint x="380" y="1420" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-120" value="open &quot;Task&quot; page" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="395" y="1403" width="138" height="13" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-121" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="379" y="1454" as="sourcePoint" />
<mxPoint x="280" y="1454" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-122" value="retrieve all task units data" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="288" y="1431" width="88" height="17" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-123" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1530" as="sourcePoint" />
<mxPoint x="380" y="1530" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-124" value="approve/reject unit" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="395" y="1513" width="138" height="13" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-125" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="369" y="1549" as="sourcePoint" />
<mxPoint x="280" y="1533" as="targetPoint" />
<Array as="points">
<mxPoint x="350" y="1533" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-126" value="update task unit and record unit review" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="275" y="1510" width="106" height="17" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-128" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="370" y="1549" as="sourcePoint" />
<mxPoint x="180" y="1569" as="targetPoint" />
<Array as="points">
<mxPoint x="350" y="1569" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-129" value="pay bonus or reject/block (as needed)" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="178" y="1552" width="180" height="13" as="geometry" />
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-137" value="" style="endArrow=classic;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="560" y="1387" as="sourcePoint" />
<mxPoint x="380" y="1387" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="3-yWvNHymt2EtWyProw8-138" value="check responses stats page" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="395" y="1370" width="155" height="13" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-1" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="380" y="1549" as="sourcePoint" />
<mxPoint x="370" y="1549" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-2" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="380" y="1290" as="sourcePoint" />
<mxPoint x="560" y="1290" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-3" value="serve TaskReview app in browser" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="388" y="1273" width="165" height="13" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-4" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="380" y="1700" as="sourcePoint" />
<mxPoint x="560" y="1700" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-5" value="&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;redirect to &quot;Tasks&quot; page&lt;/span&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="423" y="1682" width="112" height="13" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-6" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="380" y="1501" as="sourcePoint" />
<mxPoint x="560" y="1501" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-7" value="&lt;font color=&quot;#333333&quot;&gt;display next task unit to review&lt;/font&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="388" y="1484" width="165" height="13" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0.002;entryY=0.113;entryDx=0;entryDy=0;curved=0;entryPerimeter=0;" edge="1" parent="1" source="5EaqwkNcLw-vjFIcxztH-8" target="5EaqwkNcLw-vjFIcxztH-12">
<mxGeometry relative="1" as="geometry">
<mxPoint x="190" y="1650" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-8" value="all&lt;br&gt;task units&lt;br&gt;reviewed?" style="rhombus;whiteSpace=wrap;html=1;fontSize=10;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="340" y="1600" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-9" value="&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;YES&lt;/span&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="381" y="1680" width="21" height="13" as="geometry" />
</mxCell>
<mxCell id="5EaqwkNcLw-vjFIcxztH-11" value="&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;NO&lt;/span&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="318" y="1623" width="21" height="13" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
8 changes: 4 additions & 4 deletions examples/form_composer_demo/run_task_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from omegaconf import DictConfig

from mephisto.client.cli import FORM_COMPOSER__DATA_CONFIG_NAME
from mephisto.client.cli import FORM_COMPOSER__DATA_DIR_NAME
from mephisto.client.cli import FORM_COMPOSER__FORM_CONFIG_NAME
from mephisto.client.cli import FORM_COMPOSER__TOKEN_SETS_VALUES_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__DATA_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__DATA_DIR_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__FORM_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__TOKEN_SETS_VALUES_CONFIG_NAME
from mephisto.generators.form_composer.config_validation.task_data_config import (
create_extrapolated_config,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from mephisto.abstractions.blueprints.abstract.static_task.static_blueprint import (
SharedStaticTaskState,
)
from mephisto.client.cli import FORM_COMPOSER__DATA_CONFIG_NAME
from mephisto.client.cli import FORM_COMPOSER__DATA_DIR_NAME
from mephisto.client.cli import FORM_COMPOSER__FORM_CONFIG_NAME
from mephisto.client.cli import FORM_COMPOSER__TOKEN_SETS_VALUES_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__DATA_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__DATA_DIR_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__FORM_CONFIG_NAME
from mephisto.client.cli_form_composer_commands import FORM_COMPOSER__TOKEN_SETS_VALUES_CONFIG_NAME
from mephisto.generators.form_composer.config_validation.task_data_config import (
create_extrapolated_config,
)
Expand Down
Loading

0 comments on commit 5e7eb18

Please sign in to comment.