Commit 76fa06a5 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

level0_id

parent 7ab9acee
# coding: utf-8 # coding: utf-8
__version_info__ = (1, 0, 0)
__version__ = '.'.join(map(str, __version_info__))
__all__ = ['logging']
\ No newline at end of file
...@@ -4,4 +4,7 @@ def format_datetime(dt): ...@@ -4,4 +4,7 @@ def format_datetime(dt):
return dt.strftime('%Y-%m-%d %H:%M:%S') return dt.strftime('%Y-%m-%d %H:%M:%S')
def format_date(dt): def format_date(dt):
return dt.strftime('%Y-%m-%d') return dt.strftime('%Y-%m-%d')
\ No newline at end of file
def format_sql_datetime(dt):
return str(dt) if isinstance(dt, datetime) else dt
\ No newline at end of file
...@@ -12,11 +12,11 @@ import logging.handlers ...@@ -12,11 +12,11 @@ import logging.handlers
def setup_logging(): def setup_logging():
""" Setup logging configuration """ """ Setup logging configuration """
# Console formatter, mention name cfmt = logging.Formatter(('%(asctime)s- %(name)s - %(filename)s - %(levelname)s - %(message)s'))
cfmt = logging.Formatter(('%(name)s - %(levelname)s - %(message)s'))
# File formatter, mention time # File formatter, mention time
ffmt = logging.Formatter(('%(asctime)s - %(levelname)s - %(message)s')) ffmt = logging.Formatter(('%(asctime)s - %(filename)s - %(levelname)s - %(message)s'))
# Console handler # Console handler
ch = logging.StreamHandler() ch = logging.StreamHandler()
......
...@@ -8,7 +8,7 @@ class Result(dict): ...@@ -8,7 +8,7 @@ class Result(dict):
@property @property
def success(self): def success(self):
return self["code"] >= 0 return self["code"] == 0
@property @property
def data(self): def data(self):
......
...@@ -13,7 +13,9 @@ class BaseModel: ...@@ -13,7 +13,9 @@ class BaseModel:
return self return self
def from_proto_model(self, record): def from_proto_model(self, record):
return self.from_dict({r.name:v for r,v in record.ListFields()}) for k in self.__dataclass_fields__.keys():
self.__setattr__(k, record.__getattribute__(k))
return self
@dataclasses.dataclass @dataclasses.dataclass
class Gaia3Record(BaseModel): class Gaia3Record(BaseModel):
......
...@@ -6,6 +6,7 @@ from .common import BaseModel ...@@ -6,6 +6,7 @@ from .common import BaseModel
@dataclasses.dataclass @dataclasses.dataclass
class Observation(BaseModel): class Observation(BaseModel):
id: int = 0 id: int = 0
obs_id: str = ""
obs_time: str = "" obs_time: str = ""
exp_time : float = 0 exp_time : float = 0
module_id: str="" module_id: str=""
...@@ -22,18 +23,19 @@ class Observation(BaseModel): ...@@ -22,18 +23,19 @@ class Observation(BaseModel):
@dataclasses.dataclass @dataclasses.dataclass
class Level0PrcRecord(BaseModel): class Level0PrcRecord(BaseModel):
id: int = 0 id: int = 0
level0_id: int = 0 level0_id: str = ""
pipeline_id: str = "" pipeline_id: str = ""
prc_module: str = "" prc_module: str = ""
params_id: str="" params_file_path: str=""
prc_status: int = 0 prc_status: int = 0
prc_time: str="" prc_time: str=""
file_path: str="" result_file_path: str=""
@dataclasses.dataclass @dataclasses.dataclass
class Level0Record(BaseModel): class Level0Record(BaseModel):
id: int = 0 id: int = 0
obs_id: int = 0 level0_id: str = ""
obs_id: str = ""
detector_no: str = "" detector_no: str = ""
obs_type: str = "" obs_type: str = ""
obs_time: str="" obs_time: str=""
...@@ -50,6 +52,7 @@ class Level0Record(BaseModel): ...@@ -50,6 +52,7 @@ class Level0Record(BaseModel):
@dataclasses.dataclass @dataclasses.dataclass
class CalMergeRecord(BaseModel): class CalMergeRecord(BaseModel):
id: int = 0 id: int = 0
cal_id: str = ""
detector_no: str = "" detector_no: str = ""
ref_type: str = "" ref_type: str = ""
obs_time: str="" obs_time: str=""
......
...@@ -5,7 +5,7 @@ from .common import BaseModel ...@@ -5,7 +5,7 @@ from .common import BaseModel
@dataclasses.dataclass @dataclasses.dataclass
class Level1Record(BaseModel): class Level1Record(BaseModel):
id: int = 0 id: int = 0
raw_id : int = 0 level0_id : str = ""
data_type: str="" data_type: str=""
cor_sci_id: int = 0 cor_sci_id: int = 0
prc_params: str="" prc_params: str=""
......
...@@ -5,7 +5,7 @@ from .common import BaseModel ...@@ -5,7 +5,7 @@ from .common import BaseModel
@dataclasses.dataclass @dataclasses.dataclass
class Level1Record(BaseModel): class Level1Record(BaseModel):
id: int = 0 id: int = 0
raw_id : int = 0 level0_id : str = ""
data_type: str="" data_type: str=""
cor_sci_id: int = 0 cor_sci_id: int = 0
prc_params: str="" prc_params: str=""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment