Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-commons
Commits
819bce72
Commit
819bce72
authored
Aug 01, 2021
by
Wei Shoulin
Browse files
to proto model
parent
76fa06a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
csst_dfs_commons/models/__init__.py
View file @
819bce72
...
@@ -39,4 +39,19 @@ class Result(dict):
...
@@ -39,4 +39,19 @@ class Result(dict):
def
append
(
self
,
k
:
str
,
v
):
def
append
(
self
,
k
:
str
,
v
):
self
[
k
]
=
v
self
[
k
]
=
v
return
self
class
Request
(
object
):
def
__init__
(
self
):
super
(
Request
,
self
).
__init__
()
@
staticmethod
def
from_dict
(
d
:
dict
):
r
=
Request
()
for
k
,
v
in
d
.
items
():
r
.
append
(
k
,
v
)
return
r
def
append
(
self
,
k
:
str
,
v
):
self
.
__setattr__
(
k
,
v
)
return
self
return
self
\ No newline at end of file
csst_dfs_commons/models/common.py
View file @
819bce72
...
@@ -4,6 +4,8 @@ def from_proto_model_list(clazz, records):
...
@@ -4,6 +4,8 @@ def from_proto_model_list(clazz, records):
return
[
clazz
().
from_proto_model
(
r
)
for
r
in
records
]
return
[
clazz
().
from_proto_model
(
r
)
for
r
in
records
]
def
from_dict_list
(
clazz
,
records
):
def
from_dict_list
(
clazz
,
records
):
return
[
clazz
().
from_dict
(
r
)
for
r
in
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
@
dataclasses
.
dataclass
class
BaseModel
:
class
BaseModel
:
...
@@ -16,6 +18,17 @@ class BaseModel:
...
@@ -16,6 +18,17 @@ class BaseModel:
for
k
in
self
.
__dataclass_fields__
.
keys
():
for
k
in
self
.
__dataclass_fields__
.
keys
():
self
.
__setattr__
(
k
,
record
.
__getattribute__
(
k
))
self
.
__setattr__
(
k
,
record
.
__getattribute__
(
k
))
return
self
return
self
def
to_proto_model
(
self
,
protoObjClazz
):
obj
=
protoObjClazz
()
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
):
obj
.
__getattribute__
(
k
).
extend
(
v
)
else
:
obj
.
__setattr__
(
k
,
v
)
return
obj
@
dataclasses
.
dataclass
@
dataclasses
.
dataclass
class
Gaia3Record
(
BaseModel
):
class
Gaia3Record
(
BaseModel
):
...
@@ -123,14 +136,3 @@ class Gaia3Record(BaseModel):
...
@@ -123,14 +136,3 @@ class Gaia3Record(BaseModel):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
AstrometricNObsAc
=
0
self
.
AstrometricNObsAc
=
0
csst_dfs_commons/models/constants.py
0 → 100644
View file @
819bce72
UPLOAD_CHUNK_SIZE
=
1024
*
1000
*
4
STATUS_SUCESS
=
0
REF_TYPE_BIAS
=
"bias"
REF_TYPE_DARK
=
"dark"
REF_TYPE_FlAT
=
"flat"
REF_TYPE_ARC
=
"arc"
REF_TYPE_LAMP
=
"lamp"
REF_TYPE_SKY
=
"sky"
REF_TYPES
=
(
REF_TYPE_BIAS
,
REF_TYPE_DARK
,
REF_TYPE_FlAT
,
REF_TYPE_ARC
,
REF_TYPE_LAMP
,
REF_TYPE_SKY
)
OBS_TYPE_SCI
=
"sci"
OBS_TYPE_CAL
=
"cal"
OBS_TYPE_TEST
=
"test"
OBS_TYPE_JOIN
=
"join"
# joint observation fo IFS and MCI
OBS_TYPES
=
(
OBS_TYPE_SCI
,
OBS_TYPE_CAL
,
OBS_TYPE_TEST
,
OBS_TYPE_JOIN
)
MODULE_MSC
=
"MSC"
MODULE_IFS
=
"IFS"
MODULE_MCI
=
"MCI"
MODULE_CPIC
=
"CPIC"
MODULE_THZ
=
"HSTDM"
MODULES
=
(
MODULE_MSC
,
MODULE_IFS
,
MODULE_MCI
,
MODULE_CPIC
,
MODULE_THZ
)
PRC_MODULE_QC0
=
"QC0"
PRC_MODULE_QC1
=
"QC1"
PRC_MODULE_MSC_INSTRUMENT_EFFECT
=
"MSC-IE"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment