Skip to content

Commit

Permalink
auto failed, some small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr_SYX committed Mar 15, 2024
1 parent ac801c2 commit 6563343
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
10 changes: 6 additions & 4 deletions pyerm/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Version: 0.2.0
# Version: 0.2.3

import os
import typing
Expand Down Expand Up @@ -57,6 +57,7 @@ def experiment_start(self, description:str=None, start_time:float=None, tags:str
assert self._method is not None, 'Method not initialized, run method_init() first'
assert self._task is not None, 'Task not initialized, run task_init() first'
self._id = self.experiment_table.experiment_start(description, self._method, self._method_id, self._data, self._data_id, self._task, start_time, tags, experimenters)
atexit.register(self.experiment_table.experiment_failed, self._id)

def experiment_over(self, rst_dict:typing.Dict[str, typing.Union[int, float, str, bool, bytearray, bytes]], images:typing.List[typing.Union[Image.Image, str]]=[], end_time:float=None, useful_time_cost:float=None) -> None:
assert self._id is not None, 'Experiment not started, run experiment_start() first'
Expand All @@ -67,11 +68,12 @@ def experiment_over(self, rst_dict:typing.Dict[str, typing.Union[int, float, str
self.rst_table.record_rst(experiment_id=self._id, **rst_dict)
self.rst_table.record_image(self._id, images)
self.experiment_table.experiment_over(self._id, end_time=end_time, useful_time_cost=useful_time_cost)
atexit.unregister(self.experiment_table.experiment_failed)

def experiment_failed(self, exception:Exception, end_time:float=None) -> None:
def experiment_failed(self, end_time:float=None) -> None:
assert self._id is not None, 'Experiment not started, run experiment_start() first'
self.experiment_table.experiment_failed(self._id, exception, end_time=end_time)
atexit.register(self.experiment_table.experiment_failed, self._id, exception, end_time=end_time)
self.experiment_table.experiment_failed(self._id, end_time=end_time)


def detail_update(self, detail_dict:typing.Dict[str, typing.Union[int, float, str, bool, bytearray, bytes]]):
assert self._id is not None, 'Experiment not started, run experiment_start() first'
Expand Down
6 changes: 3 additions & 3 deletions pyerm/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Version: 0.2.2
# Version: 0.2.3

from PIL import Image
from io import BytesIO
Expand Down Expand Up @@ -65,12 +65,12 @@ def experiment_over(self, experiment_id:int, end_time:float=None, useful_time_co
end_time = strftime("%Y-%m-%d %H:%M:%S", end_time)
super().update(f"id={experiment_id}", end_time=strftime(end_time), useful_time_cost=useful_time_cost, status='finished')

def experiment_failed(self, experiment_id:int, exception:Exception, end_time:float=None) -> None:
def experiment_failed(self, experiment_id:int, end_time:float=None) -> None:
if end_time is None:
end_time = time()
end_time = localtime(end_time)
end_time = strftime("%Y-%m-%d %H:%M:%S", end_time)
error_info = str(exception)
error_info = traceback.format_exc()
super().update(f"id={experiment_id}", end_time=strftime(end_time), status='failed', failed_reason=error_info)

def get_experiment(self, experiment_id:int) -> dict:
Expand Down
5 changes: 3 additions & 2 deletions pyerm/webUI/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Version: 0.2.2
# Version: 0.2.3

import streamlit as st
import os
Expand All @@ -34,7 +34,8 @@
def home():
title()
load_db()
download_xls()
if os.path.exists(st.session_state.db_path) and st.session_state.db_path.endswith('.db'):
download_xls()

def title():
st.title('Python Experiment Record Manager WebUI')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Version: 0.2.2
# Version: 0.2.3
from setuptools import setup, find_packages

with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()

setup(
name='pyerm',
version='0.2.2',
version='0.2.3',
author='Yuxuan Shao',
author_email='yx_shao@qq.com',
description='This project is an local experiment record manager for python based on SQLite DMS, suitable for recording experiment and analysing experiment data with a web UI, which can help you efficiently save your experiment settings and results for later analysis.',
Expand Down

0 comments on commit 6563343

Please sign in to comment.