# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os import yaml from maro.cli.grass.utils.copy import copy_files_to_node from maro.cli.utils.params import GlobalPaths from maro.utils.logger import CliLogger logger = CliLogger(__name__) def save_cluster_details(cluster_name: str, cluster_details: dict, sync: bool = True) -> None: with open( os.path.expanduser( f"{GlobalPaths.MARO_CLUSTERS}/{cluster_name}/details.yml"), 'w') as fw: yaml.safe_dump(cluster_details, fw) if sync: _sync_cluster_details(cluster_details=cluster_details) def load_cluster_details(cluster_name: str, sync: bool = False) -> dict: with open( os.path.expanduser( f"{GlobalPaths.MARO_CLUSTERS}/{cluster_name}/details.yml"), 'r') as fr:
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import datetime import json from maro.cli.utils.subprocess import SubProcess from maro.utils.exception.cli_exception import CommandError, DeploymentError from maro.utils.logger import CliLogger logger = CliLogger(name=__name__) class AzureExecutor: # Account related @staticmethod def set_subscription(subscription: str): command = f"az account set --subscription {subscription}" _ = SubProcess.run(command) # Resource Group related @staticmethod def get_resource_group(resource_group: str): command = f"az group show --name {resource_group}" try: return_str = SubProcess.run(command) return json.loads(return_str) except CommandError:
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os import redis from maro.cli.process.utils.default_param import process_setting from maro.cli.process.utils.details import load_details, save_setting_info, start_agent, start_redis from maro.cli.utils.params import LocalPaths, ProcessRedisName from maro.utils.logger import CliLogger logger = CliLogger(name=f"ProcessExecutor.{__name__}") def create(deployment_path: str, **kwargs): current_process_path = os.path.expanduser(LocalPaths.MARO_PROCESS) # Create folder if not os.path.exists(current_process_path): os.makedirs(current_process_path) # Get environment setting setting_info = process_setting if deployment_path is not None: customized_setting = load_details(deployment_path=deployment_path) for key, value in customized_setting.items(): if key in setting_info: setting_info[key] = value save_setting_info(setting_info) logger.info(f"MARO process mode setting: {setting_info}")