示例#1
0
def restart_before_control_dependency(
    src: Channel,
    dependency: Channel,
) -> None:
    """
    Add restart-before control dependency. It means src channel will restart when and only the dependency channel stop.

    :param src: The src channel depended on the dependency channel.
    :param dependency: The channel which is the dependency.
    :return: None.
    """
    tmp = RestartBeforeControlEdge(source_node_id=src.node_id,
                                   target_node_id=dependency.node_id)
    _default_ai_graph.add_edge(src.node_id, tmp)
示例#2
0
def start_before_control_dependency(
        src: Channel,
        dependency: Channel,
        namespace: Text = DEFAULT_NAMESPACE) -> None:
    """
    Add start-before control dependency. It means src channel will start when and only the dependency channel start.

    :param namespace:
    :param src: The src channel depended on the dependency channel.
    :param dependency: The channel which is the dependency.
    :return: None.
    """
    tmp = StartBeforeControlEdge(source_node_id=src.node_id,
                                 target_node_id=dependency.node_id,
                                 namespace=namespace)
    _default_ai_graph.add_edge(src.node_id, tmp)
示例#3
0
def example_control_dependency(
    src: Channel,
    example_name: Text,
    dependency: Channel,
) -> None:
    """
    Add example control dependency. It means src channel will start when and only the an new example of the specific
    example is updated in notification service.

    :param src: The src channel depended on the example which is updated in notification service.
    :param example_name: Name of the example, refers to a specific example.
    :param dependency: The channel which is the dependency.
    :return: None.
    """
    tmp = ExampleControlEdge(example_name=example_name,
                             target_node_id=dependency.node_id,
                             source_node_id=src.node_id)
    _default_ai_graph.add_edge(src.node_id, tmp)
示例#4
0
def user_define_control_dependency(
        src: Channel,
        dependency: Channel,
        event_key: Text,
        event_value: Text,
        event_type: Text = UNDEFINED_EVENT_TYPE,
        condition: MetCondition = MetCondition.NECESSARY,
        action: TaskAction = TaskAction.START,
        life: EventLife = EventLife.ONCE,
        value_condition: MetValueCondition = MetValueCondition.EQUAL,
        namespace: Text = DEFAULT_NAMESPACE,
        sender: Text = None) -> None:
    """
    Add user defined control dependency.

    :param namespace: the project name
    :param src: The src channel depended the event which is updated in notification service.
    :param dependency: The channel which is the dependency.
    :param event_key: The key of the event.
    :param event_value: The value of the event.
    :param event_type: The Name of the event.
    :param condition: The event condition. Sufficient or Necessary.
    :param action: The action act on the src channel. Start or Restart.
    :param life: The life of the event. Once or Repeated.
    :param value_condition: The event value condition. Equal or Update. Equal means the src channel will start or
                            restart only when in the condition that the notification service updates a value which
                            equals to the event value under the specific event key, while update means src channel
                            will start or restart when in the the condition that the notification service has a update
                            operation on the event key which event value belongs to.
    :param sender: The event sender identity. If sender is None, the sender will be dependency.
    :return:None.
    """
    control_edge = UserDefineControlEdge(target_node_id=dependency.node_id,
                                         source_node_id=src.node_id,
                                         event_key=event_key,
                                         event_value=event_value,
                                         event_type=event_type,
                                         condition=condition,
                                         action=action,
                                         life=life,
                                         value_condition=value_condition,
                                         namespace=namespace,
                                         sender=sender)
    _default_ai_graph.add_edge(src.node_id, control_edge)
示例#5
0
def model_version_control_dependency(
    src: Channel,
    model_name: Text,
    model_version_event_type,
    dependency: Channel,
) -> None:
    """
    Add model version control dependency. It means src channel will start when and only a new model version of the
    specific model is updated in notification service.

    :param model_version_event_type: one of ModelVersionEventType
    :param src: The src channel depended on the new model version which is updated in notification service.
    :param model_name: Name of the model, refers to a specific model.
    :param dependency: The channel which is the dependency.
    :return: None.
    """
    tmp = ModelVersionControlEdge(model_name=model_name,
                                  model_type=model_version_event_type,
                                  target_node_id=dependency.node_id,
                                  source_node_id=src.node_id)
    _default_ai_graph.add_edge(src.node_id, tmp)