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

Updated NodeJS to v22 #1221

Merged
merged 1 commit into from
Aug 5, 2024
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
83 changes: 42 additions & 41 deletions .github/workflows/cypress-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,47 +379,48 @@ jobs:
cd mephisto/scripts/local_db/gh_actions
python expire_all_units.py

- name: 📚 Accepting the first submitted tip, accepting the second submitted tip, and rejecting the last submitted tip
run: |
cd mephisto/scripts/local_db
python review_tips_for_task.py << EOF
react-static-task-with-tips
a
5
The tip is very informative
a
0
r
EOF

- name: 🔥 Removing the second accepted tip
run: |
cd mephisto/scripts/local_db
python remove_accepted_tip.py << EOF
react-static-task-with-tips
n
y
EOF

- name: 📖 Reviewing the accepted feedback
run: |
cd mephisto/scripts/local_db
python review_feedback_for_task.py << EOF
react-static-task-with-tips
0
n
u
y
y
EOF
python review_feedback_for_task.py << EOF
react-static-task-with-tips
1
n
u
y
n
EOF
# TODO: Fix tests for WorkerOpinion widget
# - name: 📚 Accepting the first submitted tip, accepting the second submitted tip, and rejecting the last submitted tip
# run: |
# cd mephisto/scripts/local_db
# python review_tips_for_task.py << EOF
# react-static-task-with-tips
# a
# 5
# The tip is very informative
# a
# 0
# r
# EOF
#
# - name: 🔥 Removing the second accepted tip
# run: |
# cd mephisto/scripts/local_db
# python remove_accepted_tip.py << EOF
# react-static-task-with-tips
# n
# y
# EOF
#
# - name: 📖 Reviewing the accepted feedback
# run: |
# cd mephisto/scripts/local_db
# python review_feedback_for_task.py << EOF
# react-static-task-with-tips
# 0
# n
# u
# y
# y
# EOF
# python review_feedback_for_task.py << EOF
# react-static-task-with-tips
# 1
# n
# u
# y
# n
# EOF

- name: ⌛️ Running post-submission cypress tests
uses: cypress-io/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/docker-testing-matrix-manual-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
run: |
docker run mephisto_manual

- name: Run command that removes and rebuilds all React apps related to the FormComposer
# Test that all Mephisto React apps can be built
- name: Run command that removes and rebuilds all Mephisto React apps
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()
Loading
Loading