def test_list_figures(self): environ["EXPERIMENT_ID"] = "test" result = list_figures() self.assertTrue(isinstance(result, list)) environ["OPERATOR_ID"] = "test" result = list_figures() self.assertTrue(isinstance(result, list)) del environ["EXPERIMENT_ID"] del environ["OPERATOR_ID"] result = list_figures(experiment_id="test", operator_id="test") self.assertTrue(isinstance(result, list))
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 list_figures(self, project_id: str, experiment_id: str, run_id: str, operator_id: str): """ Lists all figures from object storage as data URI scheme. Parameters ---------- project_id : str experiment_id : str run_id : str The run_id. If `run_id=latest`, then returns figures from the latest run_id. operator_id : str Returns ------- list A list of data URIs. Raises ------ NotFound When any of project_id, experiment_id, run_id, or operator_id does not exist. """ figures = platiagro.list_figures(experiment_id=experiment_id, operator_id=operator_id, run_id=run_id) return figures
def test_list_figures_run_id(self): environ["EXPERIMENT_ID"] = "test" environ["OPERATOR_ID"] = "test" environ["RUN_ID"] = RUN_ID result = list_figures() self.assertTrue(isinstance(result, list)) del environ["EXPERIMENT_ID"] del environ["OPERATOR_ID"] del environ["RUN_ID"] result = list_figures(experiment_id="test", operator_id="test", run_id=RUN_ID) self.assertTrue(isinstance(result, list)) result = list_figures(experiment_id="test", operator_id="test", run_id="latest") self.assertTrue(isinstance(result, list))
def list_figures(experiment_id, operator_id, run_id): """Lists all figures from object storage as data URI scheme. Args: experiment_id (str): the experiment uuid. operator_id (str): the operator uuid. run_id (str): the run id. Returns: A list of data URIs. """ return platiagro.list_figures(experiment_id=experiment_id, operator_id=operator_id, run_id=run_id)
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 list_figures(self, project_id: str, deployment_id: str, monitoring_id: str): """ Lists all figures from object storage as data URI scheme. Parameters ---------- project_id : str deployment_id : str monitoring_id : str Returns ------- list A list of data URIs. Raises ------ NotFound When any of project_id, deployment_id, monitoring_id does not exist. """ figures = platiagro.list_figures(deployment_id=deployment_id, monitoring_id=monitoring_id) return figures