def fill_registries(): """ Ensure that all of the required modules are picked up by the mephisto server """ # TODO(#653) pick up on local file changes such that Mephisto won't need to be # restarted to add new abstractions # TODO(#653) pass through all of the use_mephisto modules in the local registry file # to ensure that all of the modules are added # TODO(WISH) these can be made recursive finds with os.walk to pass through subfolders # Import Mephisto CrowdProviders provider_root = get_provider_dir() for dir_name in os.listdir(provider_root): provider_dir = os.path.join(provider_root, dir_name) if not os.path.isdir(provider_dir): continue for filename in os.listdir(provider_dir): if filename.endswith("provider.py"): provider_name = filename[:filename.find(".py")] importlib.import_module( f"mephisto.abstractions.providers.{dir_name}.{provider_name}" ) # Import Mephisto Architects architect_root = os.path.join(get_root_dir(), "mephisto", "abstractions", "architects") for filename in os.listdir(architect_root): if filename.endswith("architect.py"): architect_name = filename[:filename.find(".py")] importlib.import_module( f"mephisto.abstractions.architects.{architect_name}") # After imports are recursive, manage this more cleanly importlib.import_module( "mephisto.abstractions.architects.ec2.ec2_architect") # Import Mephisto Blueprints blueprint_root = os.path.join(get_root_dir(), "mephisto", "abstractions", "blueprints") for dir_name in os.listdir(blueprint_root): blueprint_dir = os.path.join(blueprint_root, dir_name) if not os.path.isdir(blueprint_dir): continue for filename in os.listdir(blueprint_dir): if filename.endswith("blueprint.py"): blueprint_name = filename[:filename.find(".py")] importlib.import_module( f"mephisto.abstractions.blueprints.{dir_name}.{blueprint_name}" )
def manipulate_search_path(self, search_path: ConfigSearchPath) -> None: # Appends the search path for this plugin to the end of the search path profile_path = os.path.join(get_root_dir(), "hydra_configs") profile_path_user = os.path.join(DEFAULT_CONFIG_FOLDER, "hydra_configs") search_path.append(provider="mephisto-profiles", path=f"file://{profile_path}") search_path.append( provider="mephisto-profiles-user", path=f"file://{profile_path_user}" )
import subprocess import sys import time from mephisto.utils.dirs import get_mephisto_tmp_dir, get_root_dir from mephisto.utils.logger_core import get_logger, warn_once from prometheus_client import start_http_server from omegaconf import DictConfig from typing import Optional logger = get_logger(name=__name__) PROMETHEUS_PID_FILE = os.path.join(get_mephisto_tmp_dir(), "PROMETHEUS_PID.txt") GRAFANA_PID_FILE = os.path.join(get_mephisto_tmp_dir(), "GRAFANA_PID.txt") METRICS_DIR = os.path.join(get_root_dir(), "mephisto", "scripts", "metrics") PROMETHEUS_DIR = os.path.join(METRICS_DIR, "prometheus") PROMETHEUS_EXECUTABLE = os.path.join(PROMETHEUS_DIR, "prometheus") PROMETHEUS_CONFIG = os.path.join(PROMETHEUS_DIR, "prometheus.yml") GRAFANA_DIR = os.path.join(METRICS_DIR, "grafana") GRAFANA_EXECUTABLE = os.path.join(GRAFANA_DIR, "bin", "grafana-server") def _server_process_running(pid): """Check on the existing process id""" try: os.kill(pid, 0) except OSError as err: if err.errno == errno.ESRCH: # ESRCH == No such process return False
# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Script to pull the current version of `mephisto-task` in the repo and push that version to all files setting a CURR_MEPHISTO_TASK_VERSION constant value """ import os import sys import re import json from mephisto.utils.dirs import get_root_dir from mephisto.utils.logger_core import format_loud ROOT_DIR = get_root_dir() PATTERN = r'(CURR_MEPHISTO_TASK_VERSION = "([0-9a-zA-Z.]*)")' TARGET_FILES = [ "mephisto/abstractions/architects/router/flask/mephisto_flask_blueprint.py", "mephisto/abstractions/architects/router/node/server.js", "mephisto/abstractions/architects/router/build_router.py", ] MEPHISTO_TASK_PACKAGE = os.path.join(ROOT_DIR, "packages/mephisto-task/package.json") def run_replace(): assert os.path.exists( MEPHISTO_TASK_PACKAGE ), f"Can't find task package at {MEPHISTO_TASK_PACKAGE}" with open(MEPHISTO_TASK_PACKAGE) as mephisto_task_package:
def test_version(): with open(os.path.join(get_root_dir(), "mephisto", "VERSION")) as version_file: version = version_file.read().strip() assert __version__ == version