Skip to content

Commit

Permalink
Updated NodeJS to v22
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Aug 1, 2024
1 parent 63aa92c commit 9d0f178
Show file tree
Hide file tree
Showing 42 changed files with 1,275 additions and 959 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-testing-matrix-manual-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
- name: Run command that removes and rebuilds all React apps related to the FormComposer
run: |
docker run mephisto_manual bash -c 'mephisto scripts form_composer rebuild_all_apps'
docker run mephisto_manual bash -c 'mephisto scripts tests rebuild_all_mephisto_react_apps'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Using the -slim version below for minimal size. You may want to
# remove -slim, or switch to -alpine if encountering issues
ARG BASE_TAG=python3.9-nodejs16-slim
ARG BASE_TAG=python3.9-nodejs22-slim
ARG BASE_IMAGE=nikolaik/python-nodejs:$BASE_TAG

FROM $BASE_IMAGE
Expand Down
4 changes: 3 additions & 1 deletion docker/dockerfiles/Dockerfile.ubuntu-24.04
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | b
RUN export NVM_DIR="$HOME/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" \
&& nvm install 16 \
&& nvm install 22 \
&& ln -s $(which node) /usr/bin/node \
&& ln -s $(which npm) /usr/bin/npm

Expand All @@ -43,6 +43,8 @@ COPY . $MEPHISTO_REPO_PATH
# Upgrade pip so we can use the `pyproject.toml` without raising an error
RUN pip install --upgrade pip
# Install Python requirements
# [FOR DOCKERFILE ONLY] Requirements for Mephisto example `mnist`. Uncomment if you need them
# RUN pip install torch pillow numpy detoxify
# [FOR DOCKERFILE ONLY] `--ignore-installed` - some libs can be preinstall in Docker-system
# Use `cd /mephisto && pip install -e .` in your local environment
RUN cd /mephisto && pip install --ignore-installed -e .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" \
&& nvm install 16 \
&& nvm install 22 \
&& ln -s $(which node) /usr/bin/node \
&& ln -s $(which npm) /usr/bin/npm
npm install -g yarn
Expand Down
50 changes: 4 additions & 46 deletions examples/form_composer_demo/run_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,21 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import os

from omegaconf import DictConfig

from mephisto.operations.operator import Operator
from mephisto.tools.scripts import build_custom_bundle
from mephisto.tools.building_react_apps import examples
from mephisto.tools.scripts import task_script


@task_script(default_config_file="example_local_mock")
def main(operator: Operator, cfg: DictConfig) -> None:
# Build packages
_build_custom_bundles(cfg)

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


def _build_custom_bundles(cfg: DictConfig) -> None:
"""Locally build bundles that are not available on npm repository"""
mephisto_packages_dir = os.path.join(
# Root project directory
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
"packages",
)

# Build `mephisto-task-multipart` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="mephisto-task-multipart",
build_command="build",
)

# Build `react-form-composer` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="react-form-composer",
build_command="build",
)

# Build Review UI for the application
build_custom_bundle(
cfg.task_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="webapp",
build_command="build:simple:review",
)

# Build Task UI for the application
build_custom_bundle(
cfg.task_dir,
examples.build_form_composer_simple(
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
build_command="dev:simple",
)
operator.launch_task_run(cfg.mephisto)
operator.wait_for_runs_then_shutdown(skip_input=True, log_rate=30)


if __name__ == "__main__":
Expand Down
72 changes: 12 additions & 60 deletions examples/form_composer_demo/run_task_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,12 @@
from mephisto.generators.form_composer.config_validation.task_data_config import (
create_extrapolated_config,
)
from mephisto.generators.form_composer.config_validation.utils import set_custom_triggers_js_env_var
from mephisto.generators.form_composer.config_validation.utils import (
set_custom_validators_js_env_var,
)
from mephisto.operations.operator import Operator
from mephisto.tools.scripts import build_custom_bundle
from mephisto.tools.building_react_apps import examples
from mephisto.tools.scripts import task_script


@task_script(default_config_file="dynamic_example_local_mock")
def main(operator: Operator, cfg: DictConfig) -> None:
# Build packages
_build_custom_bundles(cfg)

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


def _build_custom_bundles(cfg: DictConfig) -> None:
"""Locally build bundles that are not available on npm repository"""
mephisto_packages_dir = os.path.join(
# Root project directory
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
"packages",
)

# Build `mephisto-task-multipart` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="mephisto-task-multipart",
build_command="build",
)

# Build `react-form-composer` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="react-form-composer",
build_command="build",
)

# Build Review UI for the application
build_custom_bundle(
cfg.task_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="webapp",
build_command="build:review",
)

# Build Task UI for the application
build_custom_bundle(
cfg.task_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)


def generate_task_data_json_config():
def _generate_task_data_json_config():
"""
Generate extrapolated `task_data.json` config file,
based on existing form and tokens values config files
Expand All @@ -95,12 +42,17 @@ def generate_task_data_json_config():
data_path=data_path,
)

# Set env var for `custom_validators.js`
set_custom_validators_js_env_var(data_path)
# Set env var for `custom_triggers.js`
set_custom_triggers_js_env_var(data_path)

@task_script(default_config_file="dynamic_example_local_mock")
def main(operator: Operator, cfg: DictConfig) -> None:
examples.build_form_composer_dynamic(
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)
operator.launch_task_run(cfg.mephisto)
operator.wait_for_runs_then_shutdown(skip_input=True, log_rate=30)


if __name__ == "__main__":
generate_task_data_json_config()
_generate_task_data_json_config()
main()
103 changes: 28 additions & 75 deletions examples/form_composer_demo/run_task_dynamic_ec2_mturk_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,79 +21,14 @@
from mephisto.generators.form_composer.config_validation.task_data_config import (
create_extrapolated_config,
)
from mephisto.generators.form_composer.config_validation.utils import set_custom_triggers_js_env_var
from mephisto.generators.form_composer.config_validation.utils import (
set_custom_validators_js_env_var,
)
from mephisto.generators.form_composer.constants import TOKEN_END_REGEX
from mephisto.generators.form_composer.constants import TOKEN_START_REGEX
from mephisto.operations.operator import Operator
from mephisto.tools.scripts import build_custom_bundle
from mephisto.tools.building_react_apps import examples
from mephisto.tools.scripts import task_script


@task_script(default_config_file="dynamic_example_ec2_mturk_sandbox")
def main(operator: Operator, cfg: DictConfig) -> None:
# Build packages
_build_custom_bundles(cfg)

shared_state = SharedStaticTaskState()

# Mephisto qualifications
shared_state.qualifications = [
# Custom Mephisto qualifications
]

# Mturk qualifications
shared_state.mturk_specific_qualifications = [
# MTurk-specific quality control qualifications
]

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


def _build_custom_bundles(cfg: DictConfig) -> None:
"""Locally build bundles that are not available on npm repository"""
mephisto_packages_dir = os.path.join(
# Root project directory
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
"packages",
)

# Build `mephisto-task-multipart` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="mephisto-task-multipart",
build_command="build",
)

# Build `react-form-composer` React package
build_custom_bundle(
mephisto_packages_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="react-form-composer",
build_command="build",
)

# Build Review UI for the application
build_custom_bundle(
cfg.task_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
webapp_name="webapp",
build_command="build:review",
)

# Build Task UI for the application
build_custom_bundle(
cfg.task_dir,
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)


def generate_data_json_config():
def _generate_data_json_config():
"""
Generate extrapolated `task_data.json` config file,
based on existing form and tokens values config files
Expand All @@ -115,13 +50,8 @@ def generate_data_json_config():
data_path=data_path,
)

# Set env var for `custom_validators.js`
set_custom_validators_js_env_var(data_path)
# Set env var for `custom_triggers.js`
set_custom_triggers_js_env_var(data_path)


def generate_preview_html():
def _generate_preview_html():
"""
Generate HTML preview of a Task (based on first form version contained in `task_data.json`)
"""
Expand Down Expand Up @@ -168,7 +98,30 @@ def generate_preview_html():
f.write(preview_template)


@task_script(default_config_file="dynamic_example_ec2_mturk_sandbox")
def main(operator: Operator, cfg: DictConfig) -> None:
examples.build_form_composer_dynamic_ec2_mturk_sandbox(
force_rebuild=cfg.mephisto.task.force_rebuild,
post_install_script=cfg.mephisto.task.post_install_script,
)

shared_state = SharedStaticTaskState()

# Mephisto qualifications
shared_state.qualifications = [
# Custom Mephisto qualifications
]

# Mturk qualifications
shared_state.mturk_specific_qualifications = [
# MTurk-specific quality control qualifications
]

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


if __name__ == "__main__":
generate_data_json_config()
generate_preview_html()
_generate_data_json_config()
_generate_preview_html()
main()
Loading

0 comments on commit 9d0f178

Please sign in to comment.