Пример #1
0
    def test_get_notebooks(self, m):
        path = '/organizations/{}/training/definitions/{}/notebooks'.format(
            ORGANIZATION_ID, JOB_DEFINITION_NAME)
        m.get(path, json=NOTEBOOK_LIST_RES)

        client = APIClient()
        ret = client.get_notebooks(ORGANIZATION_ID, JOB_DEFINITION_NAME)
        self.assertListEqual(ret, NOTEBOOK_LIST_RES)
Пример #2
0
    def test_create_notebook(self, m):
        path = '/organizations/{}/training/definitions/{}/notebooks'.format(
            ORGANIZATION_ID, JOB_DEFINITION_NAME)
        m.post(path, json=NOTEBOOK_RES)

        client = APIClient()
        ret = client.create_notebook(ORGANIZATION_ID, JOB_DEFINITION_NAME)
        self.assertDictEqual(m.request_history[0].json(), {})
        self.assertDictEqual(ret, NOTEBOOK_RES)
Пример #3
0
    def test_start_notebook(self, m):
        path = '/organizations/{}/training/definitions/{}/notebooks/{}/start'.format(
            ORGANIZATION_ID, JOB_DEFINITION_NAME, NOTEBOOK_ID)
        message_res = {"message": "abc1111111111111 started"}
        m.post(path, json=message_res)

        client = APIClient()
        ret = client.start_notebook(ORGANIZATION_ID, JOB_DEFINITION_NAME,
                                    NOTEBOOK_ID)
        self.assertDictEqual(ret, message_res)
Пример #4
0
    def test_create_notebook_with_params(self, m):
        path = '/organizations/{}/training/definitions/{}/notebooks'.format(
            ORGANIZATION_ID, JOB_DEFINITION_NAME)
        m.post(path, json=NOTEBOOK_RES)

        client = APIClient()

        ret = client.create_notebook(ORGANIZATION_ID,
                                     JOB_DEFINITION_NAME,
                                     instance_type="gpu-1",
                                     image="abeja-inc/all-gpu:18.10",
                                     notebook_type="lab")
        expected_payload = {
            "instance_type": "gpu-1",
            "image": 'abeja-inc/all-gpu:18.10',
            "notebook_type": "lab"
        }
        self.assertDictEqual(m.request_history[0].json(), expected_payload)
        self.assertDictEqual(ret, NOTEBOOK_RES)
Пример #5
0
    def test_get_notebook_recent_logs(self, m):
        path = '/organizations/{}/training/definitions/{}/notebooks/{}/recentlogs'.format(
            ORGANIZATION_ID, JOB_DEFINITION_NAME, NOTEBOOK_ID)
        message_res = {
            "events": [{
                "message":
                "start executing model with abeja-runtime-python36 (version: 0.X.X)",
                "timestamp": "2019-10-16T00:00:00.000Z"
            }],
            "next_backward_token":
            "AAA",
            "next_forward_token":
            "BBB"
        }
        m.get(path, json=message_res)

        client = APIClient()
        ret = client.get_notebook_recent_logs(ORGANIZATION_ID,
                                              JOB_DEFINITION_NAME, NOTEBOOK_ID)
        self.assertDictEqual(ret, message_res)