コード例 #1
0
ファイル: test_ion_structure.py プロジェクト: vakjha1/mlpiper
def test_ion_structure():

    print("MyION = {}".format(mlops.get_mlapp_id()))
    print("Nodes:")
    for n in mlops.get_nodes():
        print(n)
    print("\n\n")
    # Getting the ION component object

    curr_node = mlops.get_current_node()
    curr_node_2 = mlops.get_node(curr_node.name)
    if curr_node_2 is None:
        raise Exception("Expecting {} node to exist in this ION".format(
            curr_node.name))
    print("C0:\n{}".format(curr_node))

    assert curr_node.name == curr_node_2.name

    # Getting the first agent of ion component "0"
    print("Getting node {} agents type of arg:{}".format(
        curr_node.name, type(curr_node.name)))

    agent_list = mlops.get_agents(curr_node.name)

    if len(agent_list) == 0:
        print("Error - must have agents this ion node is running on")
        raise Exception("Agent list is empty")

    for agent in agent_list:
        if agent is None:
            raise Exception("Agent object obtained is None")
        print("Agent: {}".format(agent))
コード例 #2
0
ファイル: test_mlops.py プロジェクト: pavantyagi/mlpiper
def test_mlops_structure_api():
    ion_instance_id = ION1.ION_INSTANCE_ID
    ion_node_id = ION1.NODE_1_ID
    token = ION1.TOKEN

    set_mlops_env(ion_id=ion_instance_id,
                  ion_node_id=ion_node_id,
                  token=token,
                  model_id=ION1.MODEL_ID)
    rest_helper = MlOpsRestFactory().get_rest_helper(MLOpsMode.AGENT,
                                                     mlops_server="localhost",
                                                     mlops_port="3456",
                                                     token=token)

    rest_helper.set_prefix(Constants.URL_MLOPS_PREFIX)
    with requests_mock.mock() as m:
        m.get(rest_helper.url_get_workflow_instance(ion_instance_id),
              json=test_workflow_instances)
        m.get(rest_helper.url_get_ees(), json=test_ee_info)
        m.get(rest_helper.url_get_agents(), json=test_agents_info)
        m.get(rest_helper.url_get_model_list(), json=test_models_info)
        m.get(rest_helper.url_get_health_thresholds(ion_instance_id),
              json=test_health_info)
        m.get(rest_helper.url_get_model_stats(ION1.MODEL_ID),
              json=test_model_stats)
        m.get(rest_helper.url_get_uuid("model"),
              json={"id": "model_5906255e-0a3d-4fef-8653-8d41911264fb"})

        pm.init(ctx=None, mlops_mode=MLOpsMode.AGENT)
        assert pm.get_mlapp_id() == ION1.ION_ID
        assert pm.get_mlapp_name() == ION1.ION_NAME

        curr_node = pm.get_current_node()
        assert curr_node.id == ion_node_id

        nodes = pm.get_nodes()
        assert len(nodes) == 2

        node0 = pm.get_node('1')
        assert node0 is not None
        assert node0.pipeline_pattern_id == ION1.PIPELINE_PATTERN_ID_1
        assert node0.pipeline_instance_id == ION1.PIPELINE_INST_ID_1

        node0_agents = pm.get_agents('1')
        assert len(node0_agents) == 1
        assert node0_agents[0].id == ION1.AGENT_ID_0
        assert node0_agents[0].hostname == 'localhost'

        agent = pm.get_agent('1', ION1.AGENT_ID_0)
        assert agent.id == ION1.AGENT_ID_0
        assert agent.hostname == 'localhost'

        model = pm.current_model()
        assert model is not None
        assert model.metadata.modelId == ION1.MODEL_ID

        pm.done()
コード例 #3
0
ファイル: main.py プロジェクト: theromis/mlhub
def get_my_agents():
    """
    Return agent list of current ION node
    :return: Agent list used by current ION node
    """

    # Getting the first agent of ion component "0"
    agent_list = mlops.get_agents(mlops.get_current_node().name)
    if len(agent_list) == 0:
        print("Error - must have agents this ion component is running on")
        raise Exception("Agent list is empty")
    return agent_list
コード例 #4
0
ファイル: utils.py プロジェクト: vakjha1/mlpiper
def _get_agent_id(node_name, agent_host_name):
    component = mlops.get_node(node_name)
    if component is None:
        raise Exception("Expecting '{}' node to exist in this {}".format(
            node_name, Constants.ION_LITERAL))

    agent_list = mlops.get_agents(node_name)
    if len(agent_list) == 0:
        print("Error - No agents found for node : '{}'".format(node_name))
        raise Exception("Agent list is empty")

    for agent in agent_list:
        print("Agents: {} {}".format(agent.id, agent.hostname))

    try:
        agent = [
            agent for agent in agent_list if agent.hostname == agent_host_name
        ]
        return agent[0].id
    except Exception as e:
        print("Got exception: No agent found")
        return None