def setUp(self): self.maxDiff = None t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) platiagro.save_figure(experiment_id=EXPERIMENT_ID, operator_id=OPERATOR_ID, run_id=RUN_ID, figure=fig)
def test_save_html_figure_deploy_monit_id(self): environ["DEPLOYMENT_ID"] = "testHtmlFigure" environ["MONITORING_ID"] = "testHtmlFigure" html_figure = '<html><body></body></html>' save_figure(figure=html_figure, extension='html') expected = [ 'data:text/html;base64,PGh0bWw+PGJvZHk+PC9ib2R5PjwvaHRtbD4=' ] self.assertEqual(expected, list_figures()) del environ["DEPLOYMENT_ID"] del environ["MONITORING_ID"]
def test_save_html_figure(self): environ["EXPERIMENT_ID"] = "testHtmlFigure" environ["OPERATOR_ID"] = "testHtmlFigure" environ["RUN_ID"] = RUN_ID html_figure = '<html><body></body></html>' save_figure(figure=html_figure, extension='html') expected = [ 'data:text/html;base64,PGh0bWw+PGJvZHk+PC9ib2R5PjwvaHRtbD4=' ] self.assertEqual(expected, list_figures()) del environ["EXPERIMENT_ID"] del environ["OPERATOR_ID"] del environ["RUN_ID"]
def test_save_figure_base64(self): with open("./tests/figure.png", "rb") as image_file: encoded_string = base64.b64encode(image_file.read()) environ["EXPERIMENT_ID"] = "testFigureBase64" environ["OPERATOR_ID"] = "testFigureBase64" environ["RUN_ID"] = RUN_ID save_figure(figure=encoded_string.decode('utf-8'), extension='png') save_figure(figure=encoded_string.decode('utf-8'), extension='svg', run_id="latest") result = list_figures() self.assertTrue(len(result) == 2) result = list_figures(run_id="latest") self.assertTrue(len(result) == 2)
def setUp(self): self.maxDiff = None conn = engine.connect() text = ( f"INSERT INTO projects (uuid, name, created_at, updated_at) " f"VALUES (%s, %s, %s, %s)" ) conn.execute(text, (PROJECT_ID, NAME, CREATED_AT, UPDATED_AT,)) text = ( f"INSERT INTO experiments (uuid, name, project_id, position, is_active, created_at, updated_at) " f"VALUES (%s, %s, %s, %s, %s, %s, %s)" ) conn.execute(text, (EXPERIMENT_ID, NAME, PROJECT_ID, POSITION, 1, CREATED_AT, UPDATED_AT,)) text = ( f"INSERT INTO tasks (uuid, name, description, image, commands, arguments, tags, parameters, experiment_notebook_path, deployment_notebook_path, is_default, created_at, updated_at) " f"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" ) conn.execute(text, (TASK_ID, NAME, DESCRIPTION, IMAGE, COMMANDS_JSON, ARGUMENTS_JSON, TAGS_JSON, dumps([]), EXPERIMENT_NOTEBOOK_PATH, DEPLOYMENT_NOTEBOOK_PATH, 0, CREATED_AT, UPDATED_AT,)) text = ( f"INSERT INTO operators (uuid, experiment_id, task_id, parameters, created_at, updated_at) " f"VALUES (%s, %s, %s, %s, %s, %s)" ) conn.execute(text, (OPERATOR_ID, EXPERIMENT_ID, TASK_ID, PARAMETERS_JSON, CREATED_AT, UPDATED_AT,)) conn.close() t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) platiagro.save_figure(experiment_id=EXPERIMENT_ID, operator_id=OPERATOR_ID, run_id=RUN_ID, figure=fig)