# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# this import is to let existing scripts import from nvflare.private.defs
from nvflare.fuel.f3.cellnet.defs import CellChannel, CellChannelTopic, SSLConstants # noqa: F401
from nvflare.fuel.f3.message import Message
from nvflare.fuel.hci.server.constants import ConnProps
[docs]
class SpecialTaskName(object):
TRY_AGAIN = "__try_again__"
END_RUN = "__end_run__"
[docs]
class TaskConstant(object):
WAIT_TIME = "__wait_time__"
[docs]
class EngineConstant(object):
FEDERATE_CLIENT = "federate_client"
FL_TOKEN = "fl_token"
CLIENT_TOKEN_FILE = "client_token.txt"
ENGINE_TASK_NAME = "engine_task_name"
[docs]
class InfoCollectorTopic(object):
SHOW_STATS = "info.show_stats"
SHOW_ERRORS = "info.show_errors"
RESET_ERRORS = "info.reset_errors"
[docs]
class ComponentCallerTopic(object):
CALL_COMPONENT = "comp_caller.call"
[docs]
class TrainingTopic(object):
START = "train.start"
ABORT = "train.abort"
ABORT_TASK = "train.abort_task"
DELETE_RUN = "train.delete_run"
DEPLOY = "train.deploy"
SHUTDOWN = "train.shutdown"
RESTART = "train.restart"
CHECK_STATUS = "train.check_status"
SET_JOB_ID = "train.set_job_id"
CHECK_RESOURCE = "scheduler.check_resource"
ALLOCATE_RESOURCE = "scheduler.allocate_resource"
CANCEL_RESOURCE = "scheduler.cancel_resource"
START_JOB = "train.start_job"
GET_SCOPES = "train.get_scopes"
NOTIFY_JOB_STATUS = "train.notify_job_status"
[docs]
class SysCommandTopic(object):
SYS_INFO = "sys.info"
SHELL = "sys.shell"
REPORT_RESOURCES = "resource_manager.report_resources"
REPORT_ENV = "sys.report_env"
[docs]
class ControlCommandTopic(object):
DO_COMMAND = "control.do_command"
[docs]
class ControlCommandName(object):
ABORT_TASK = "abort_task"
END_RUN = "end_run"
[docs]
class ClientStatusKey(object):
JOB_ID = "job_id"
CURRENT_TASK = "current_task"
STATUS = "status"
APP_NAME = "app_name"
CLIENT_NAME = "client_name"
RUNNING_JOBS = "running_jobs"
[docs]
class ScopeInfoKey(object):
SCOPE_NAMES = "scope_names"
DEFAULT_SCOPE = "default_scope"
# TODO:: Remove some of these constants
[docs]
class AppFolderConstants:
"""hard coded file names inside the app folder."""
CONFIG_TRAIN = "config_train.json"
CONFIG_ENV = "environment.json"
ERROR_MSG_PREFIX = "NVFLARE_ERROR"
[docs]
class JobFailureMsgKey:
JOB_ID = "job_id"
CODE = "code"
REASON = "reason"
[docs]
def new_cell_message(headers: dict, payload=None):
msg_headers = {}
if headers:
msg_headers.update(headers)
return Message(msg_headers, payload)