Commit bdd69410 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

level1 and sls

parent 819bce72
......@@ -39,3 +39,5 @@ test_reports.xml
**/build/
**/dist/
**/_version.py
.hypothesis
\ No newline at end of file
import dataclasses
import copy
from dataclasses import dataclass, field
def from_proto_model_list(clazz, records):
return [clazz().from_proto_model(r) for r in records]
def from_dict_list(clazz, records):
return [clazz().from_dict(r) for r in records]
def to_proto_model_list(protoObjClazz, records):
return [r.to_proto_model(protoObjClazz) for r in records]
@dataclasses.dataclass
def default_field(obj):
return field(default_factory=lambda: copy.copy(obj))
@dataclass
class BaseModel:
def from_dict(self, data = {}):
......@@ -24,13 +30,15 @@ class BaseModel:
for k in self.__dataclass_fields__.keys():
v = self.__getattribute__(k)
if v is not None:
if isinstance(v, list) or isinstance(v, tuple) or isinstance(v, dict):
if isinstance(v, list) or isinstance(v, tuple):
obj.__getattribute__(k).extend(v)
if isinstance(v, dict):
obj.__getattribute__(k).update(v)
else:
obj.__setattr__(k, v)
return obj
@dataclasses.dataclass
@dataclass
class Gaia3Record(BaseModel):
SourceId: int = -1
RandomIndex: int = -1
......
......@@ -84,3 +84,14 @@ class DetectorStatus(BaseModel):
status: str=""
create_time: str=""
status_time: str=""
@dataclasses.dataclass
class Level1PrcRecord(BaseModel):
id: int = 0
level1_id: int = 0
pipeline_id: str = ""
prc_module: str = ""
params_file_path: str=""
prc_status: int = 0
prc_time: str=""
result_file_path: str=""
\ No newline at end of file
import dataclasses
from .common import BaseModel
@dataclasses.dataclass
from dataclasses import dataclass
from typing import Dict
from .common import BaseModel, default_field
@dataclass
class Level1Record(BaseModel):
id: int = 0
level0_id : str = ""
data_type: str=""
cor_sci_id: int = 0
prc_params: str=""
flat_id: int = 0
dark_id: int = 0
bias_id: int = 0
lamp_id: int = 0
arc_id: int = 0
sky_id: int = 0
filename : str=""
file_path: str=""
qc1_status: int = 0
......@@ -23,6 +17,7 @@ class Level1Record(BaseModel):
prc_time: str=""
create_time: str=""
pipeline_id: str=""
refs: Dict[str,int] = default_field({})
......
import dataclasses
from .common import BaseModel
@dataclasses.dataclass
from dataclasses import dataclass
from typing import Dict
from .common import BaseModel, default_field
@dataclass
class Level1Record(BaseModel):
id: int = 0
level0_id : str = ""
data_type: str=""
cor_sci_id: int = 0
prc_params: str=""
flat_id: int = 0
dark_id: int = 0
bias_id: int = 0
filename : str=""
file_path: str=""
qc1_status: int = 0
......@@ -20,6 +16,7 @@ class Level1Record(BaseModel):
prc_time: str=""
create_time: str=""
pipeline_id: str=""
refs: Dict[str,int] = default_field({})
......
from dataclasses import dataclass
from typing import Dict
from .common import BaseModel, default_field
@dataclass
class Level1Record(BaseModel):
id: int = 0
level0_id : str = ""
data_type: str=""
prc_params: str=""
filename : str=""
file_path: str=""
qc1_status: int = 0
qc1_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
pipeline_id: str=""
refs: Dict[str,int] = default_field({})
@dataclass
class Level2Spectra(BaseModel):
id: int = 0
spectra_id : str = ""
level1_id: int=0
region: str=""
filename : str=""
file_path: str=""
qc1_status: int = 0
qc1_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
pipeline_id: 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