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-api
Commits
d41f24f8
Commit
d41f24f8
authored
Apr 22, 2022
by
Wei Shoulin
Browse files
brick
parent
e76c47ac
Changes
40
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
d41f24f8
...
...
@@ -6,7 +6,7 @@ This package provides APIs to access csst's files and databases.
## Installation
`csst-dfs-api`
can be installed with the following command:
`csst-dfs-api`
can be installed with the following command:
```
bash
git clone https://github.com/astronomical-data-processing/csst-dfs-api.git
...
...
@@ -20,11 +20,11 @@ python setup.py install
```
bash
sh
-c
"
$(
curl
-fsSL
https://raw.fastgit.org/astronomical-data-processing/csst-dfs-api/master/tools/csst-dfs-api-install.sh
)
"
```
## Configuration
enviroment variables
-
CSST_DFS_API_MODE = local or cluster # default: local
-
CSST_LOCAL_FILE_ROOT = [a local file directory] # required if DFS_API_MODE = local, default: /opt/temp/csst
-
CSST_DFS_GATEWAY = [gateway server's address] # required if DFS_API_MODE = cluster
csst_dfs_api/facility/__init__.py
View file @
d41f24f8
from
..ifs.calmerge
import
CalMergeApi
from
.detector
import
DetectorApi
from
.
level0
import
Level0Data
Api
from
.level
0
pr
c
import
Level
0
Pr
c
Api
from
.
brick
import
Brick
Api
from
.level
2
pr
oducer
import
Level
2
Pr
oducer
Api
from
.observation
import
ObservationApi
\ No newline at end of file
csst_dfs_api/facility/brick.py
0 → 100644
View file @
d41f24f8
from
..common.delegate
import
Delegate
class
BrickApi
(
object
):
"""
Brick Data Operation API
"""
def
__init__
(
self
):
self
.
pymodule
=
Delegate
().
load
(
sub_module
=
"facility"
)
self
.
stub
=
getattr
(
self
.
pymodule
,
"BrickApi"
)()
def
find
(
self
,
**
kwargs
):
''' retrieve brick records from database
:param kwargs: Parameter dictionary, support:
limit: limits returns the number of records,default 0:no-limit
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find
(
**
kwargs
)
def
get
(
self
,
**
kwargs
):
''' fetch a record from database
:param kwargs: Parameter dictionary, key items support:
id : [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
get
(
**
kwargs
)
def
write
(
self
,
**
kwargs
):
''' insert a brick data record into database
:param kwargs: Parameter dictionary, key items support:
ra = [float]
\n
dec = [float]
\n
boundingbox = [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
write
(
**
kwargs
)
def
find_obs_status
(
self
,
**
kwargs
):
''' find observation status of bricks
:param kwargs: Parameter dictionary, support:
brick_id = [int]
\n
band = [string]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find_obs_status
(
**
kwargs
)
def
find_level1_data
(
self
,
**
kwargs
):
''' find level1 data
:param kwargs: Parameter dictionary, support:
brick_id = [int]
\n
level1_id = [int]
\n
module = [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find_level1_data
(
**
kwargs
)
\ No newline at end of file
csst_dfs_api/facility/level2producer.py
0 → 100644
View file @
d41f24f8
from
..common.delegate
import
Delegate
class
Level2ProducerApi
(
object
):
"""
Level 0 Data Operation API
"""
def
__init__
(
self
):
self
.
pymodule
=
Delegate
().
load
(
sub_module
=
"facility"
)
self
.
stub
=
getattr
(
self
.
pymodule
,
"Level2ProducerApi"
)()
def
register
(
self
,
**
kwargs
):
''' register a Level2Producer data record into database
:param kwargs: Parameter dictionary, key items support:
name = [str]
\n
gitlink = [str]
\n
paramfiles = [str]
\n
priority = [int]
\n
pre_producers = list[int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
register
(
**
kwargs
)
def
find
(
self
,
**
kwargs
):
''' retrieve Level2Producer records from database
:param kwargs: Parameter dictionary, key items support:
key: [str]
limit: limits returns the number of records,default 0:no-limit
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find
(
**
kwargs
)
def
get
(
self
,
**
kwargs
):
''' fetch a record from database
:param kwargs: Parameter dictionary, key items support:
id : [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
get
(
**
kwargs
)
def
find_nexts
(
self
,
**
kwargs
):
''' retrieve Level2Producer records from database
:param kwargs: Parameter dictionary, key items support:
id : [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find_nexts
(
**
kwargs
)
def
find_start
(
self
,
**
kwargs
):
''' retrieve Level2Producer records from database
:param kwargs: Parameter dictionary, key items support:
key : [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find_nexts
(
**
kwargs
)
def
update
(
self
,
**
kwargs
):
''' update a Level2Producer
:param kwargs: Parameter dictionary, key items support:
id : [int]
\n
name = [str]
\n
gitlink = [str]
\n
paramfiles = [str]
\n
priority = [int]
\n
pre_producers = list[int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
update
(
**
kwargs
)
def
delete
(
self
,
**
kwargs
):
''' delete a Level2Producer data
:param kwargs: Parameter dictionary, key items support:
id = [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
delete
(
**
kwargs
)
def
new_job
(
self
,
**
kwargs
):
''' new a Level2Producer Job
:param kwargs: Parameter dictionary, key items support:
dag = [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
new_job
(
**
kwargs
)
def
get_job
(
self
,
**
kwargs
):
''' fetch a record from database
:param kwargs: Parameter dictionary, key items support:
id : [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
get_job
(
**
kwargs
)
def
update_job
(
self
,
**
kwargs
):
''' update a Level2Producer Job
:param kwargs: Parameter dictionary, key items support:
id = [int]
dag = [str]
status = [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
new_job
(
**
kwargs
)
def
new_running
(
self
,
**
kwargs
):
''' insert a Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
job_id = [int]
\n
producer_id = [int]
\n
brick_id = [int]
\n
start_time = [str]
\n
end_time = [str]
\n
prc_status = [int]
\n
prc_result = [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
new_running
(
**
kwargs
)
def
get_running
(
self
,
**
kwargs
):
''' fetch a record from database
:param kwargs: Parameter dictionary, key items support:
id : [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
get_running
(
**
kwargs
)
def
update_running
(
self
,
**
kwargs
):
''' udpate a Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
id = [int]
\n
job_id = [int]
\n
producer_id = [int]
\n
brick_id = [int]
\n
start_time = [str]
\n
end_time = [str]
\n
prc_status = [int]
\n
prc_result = [str]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
update_running
(
**
kwargs
)
def
find_running
(
self
,
**
kwargs
):
''' find Level2ProducerRuningRecord data
:param kwargs: Parameter dictionary, key items support:
job_id = [int]
\n
producer_id = [int]
\n
brick_id = [int]
\n
prc_status = [int]
\n
create_time : (start, end)
\n
limit = [int]
:returns: csst_dfs_common.models.Result
'''
return
self
.
stub
.
find_running
(
**
kwargs
)
csst_dfs_api/ifs/__init__.py
View file @
d41f24f8
from
.level1
import
Level1DataApi
\ No newline at end of file
from
.calmerge
import
CalMergeApi
from
.level0
import
Level0DataApi
from
.level0prc
import
Level0PrcApi
from
.level1
import
Level1DataApi
from
.level1prc
import
Level1PrcApi
\ No newline at end of file
csst_dfs_api/ifs/calmerge.py
View file @
d41f24f8
...
...
@@ -6,7 +6,7 @@ class CalMergeApi(object):
Level 0 Data Operation API
"""
def
__init__
(
self
):
self
.
pymodule
=
Delegate
().
load
(
sub_module
=
"
facility
"
)
self
.
pymodule
=
Delegate
().
load
(
sub_module
=
"
ifs
"
)
self
.
stub
=
getattr
(
self
.
pymodule
,
"CalMergeApi"
)()
def
find
(
self
,
**
kwargs
):
...
...
csst_dfs_api/mci/__init__.py
View file @
d41f24f8
from
.calmerge
import
CalMergeApi
from
.level0
import
Level0DataApi
from
.level0prc
import
Level0PrcApi
from
.level1
import
Level1DataApi
from
.level1prc
import
Level1PrcApi
\ No newline at end of file
csst_dfs_api/msc/__init__.py
View file @
d41f24f8
from
.level1
import
Level1DataApi
\ No newline at end of file
from
.calmerge
import
CalMergeApi
from
.level0
import
Level0DataApi
from
.level0prc
import
Level0PrcApi
from
.level1
import
Level1DataApi
from
.level1prc
import
Level1PrcApi
from
.level2catalog
import
Level2CatalogApi
\ No newline at end of file
csst_dfs_api/sls/__init__.py
View file @
d41f24f8
from
.calmerge
import
CalMergeApi
from
.level0
import
Level0DataApi
from
.level0prc
import
Level0PrcApi
from
.level1
import
Level1DataApi
from
.level1prc
import
Level1PrcApi
from
.level2spectra
import
Level2SpectraApi
\ No newline at end of file
docs/source/introduction.rst
View file @
d41f24f8
...
...
@@ -2,4 +2,8 @@
Introduction
************
This package provides APIs to access CSST's files and databases.
\ No newline at end of file
This package provides APIs to access CSST's files and databases.
.. image:: _static/csst_arch-API.jpg
:align: center
:alt: Architecture
\ No newline at end of file
docs/source/rst/csst_dfs_api.facility.rst
View file @
d41f24f8
...
...
@@ -4,10 +4,10 @@ csst\_dfs\_api.facility package
Submodules
----------
csst\_dfs\_api.facility.
calmerge
module
------------------------------------
---
csst\_dfs\_api.facility.
brick
module
------------------------------------
.. automodule:: csst_dfs_api.facility.
calmerge
.. automodule:: csst_dfs_api.facility.
brick
:members:
:undoc-members:
:show-inheritance:
...
...
@@ -20,18 +20,10 @@ csst\_dfs\_api.facility.detector module
:undoc-members:
:show-inheritance:
csst\_dfs\_api.facility.level0 module
-------------------------------------
.. automodule:: csst_dfs_api.facility.level0
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.facility.level0prc module
----------------------------------------
csst\_dfs\_api.facility.level2producer module
---------------------------------------------
.. automodule:: csst_dfs_api.facility.level
0
pr
c
.. automodule:: csst_dfs_api.facility.level
2
pr
oducer
:members:
:undoc-members:
:show-inheritance:
...
...
docs/source/rst/csst_dfs_api.ifs.rst
View file @
d41f24f8
...
...
@@ -4,6 +4,30 @@ csst\_dfs\_api.ifs package
Submodules
----------
csst\_dfs\_api.ifs.calmerge module
----------------------------------
.. automodule:: csst_dfs_api.ifs.calmerge
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.ifs.level0 module
--------------------------------
.. automodule:: csst_dfs_api.ifs.level0
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.ifs.level0prc module
-----------------------------------
.. automodule:: csst_dfs_api.ifs.level0prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.ifs.level1 module
--------------------------------
...
...
@@ -12,6 +36,14 @@ csst\_dfs\_api.ifs.level1 module
:undoc-members:
:show-inheritance:
csst\_dfs\_api.ifs.level1prc module
-----------------------------------
.. automodule:: csst_dfs_api.ifs.level1prc
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
...
...
docs/source/rst/csst_dfs_api.mci.rst
View file @
d41f24f8
csst\_dfs\_api.mci package
==========================
Submodules
----------
csst\_dfs\_api.mci.calmerge module
----------------------------------
.. automodule:: csst_dfs_api.mci.calmerge
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.mci.level0 module
--------------------------------
.. automodule:: csst_dfs_api.mci.level0
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.mci.level0prc module
-----------------------------------
.. automodule:: csst_dfs_api.mci.level0prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.mci.level1 module
--------------------------------
.. automodule:: csst_dfs_api.mci.level1
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.mci.level1prc module
-----------------------------------
.. automodule:: csst_dfs_api.mci.level1prc
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
...
...
docs/source/rst/csst_dfs_api.msc.rst
View file @
d41f24f8
...
...
@@ -4,6 +4,30 @@ csst\_dfs\_api.msc package
Submodules
----------
csst\_dfs\_api.msc.calmerge module
----------------------------------
.. automodule:: csst_dfs_api.msc.calmerge
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.msc.level0 module
--------------------------------
.. automodule:: csst_dfs_api.msc.level0
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.msc.level0prc module
-----------------------------------
.. automodule:: csst_dfs_api.msc.level0prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.msc.level1 module
--------------------------------
...
...
@@ -12,6 +36,22 @@ csst\_dfs\_api.msc.level1 module
:undoc-members:
:show-inheritance:
csst\_dfs\_api.msc.level1prc module
-----------------------------------
.. automodule:: csst_dfs_api.msc.level1prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.msc.level2catalog module
---------------------------------------
.. automodule:: csst_dfs_api.msc.level2catalog
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
...
...
docs/source/rst/csst_dfs_api.rst
View file @
d41f24f8
...
...
@@ -14,6 +14,7 @@ Subpackages
csst_dfs_api.ifs
csst_dfs_api.mci
csst_dfs_api.msc
csst_dfs_api.sls
Module contents
---------------
...
...
docs/source/rst/csst_dfs_api.sls.rst
0 → 100644
View file @
d41f24f8
csst\_dfs\_api.sls package
==========================
Submodules
----------
csst\_dfs\_api.sls.calmerge module
----------------------------------
.. automodule:: csst_dfs_api.sls.calmerge
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.sls.level0 module
--------------------------------
.. automodule:: csst_dfs_api.sls.level0
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.sls.level0prc module
-----------------------------------
.. automodule:: csst_dfs_api.sls.level0prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.sls.level1 module
--------------------------------
.. automodule:: csst_dfs_api.sls.level1
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.sls.level1prc module
-----------------------------------
.. automodule:: csst_dfs_api.sls.level1prc
:members:
:undoc-members:
:show-inheritance:
csst\_dfs\_api.sls.level2spectra module
---------------------------------------
.. automodule:: csst_dfs_api.sls.level2spectra
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: csst_dfs_api.sls
:members:
:undoc-members:
:show-inheritance:
examples/demo_facility_level0.py
View file @
d41f24f8
from
csst_dfs_api.facility.
level0
import
Level0DataApi
from
csst_dfs_api.facility.
brick
import
Level0DataApi
api
=
Level0DataApi
()
...
...
tests/test_common_catalog.py
→
tests/
common/
test_common_catalog.py
View file @
d41f24f8
File moved
tests/facility/test_facility_brick.py
0 → 100644
View file @
d41f24f8
import
os
import
unittest
from
csst_dfs_api.facility.brick
import
BrickApi
class
FacilityBrickTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
api
=
BrickApi
()
def
test_find
(
self
):
recs
=
self
.
api
.
find
(
module_id
=
"MSC"
,
limit
=
0
)
print
(
'find:'
,
recs
)
def
test_get
(
self
):
rec
=
self
.
api
.
get
(
id
=
17
)
print
(
'get:'
,
rec
)
rec
=
self
.
api
.
get
(
obs_id
=
'0000017'
)
print
(
'get:'
,
rec
)
def
test_update_proc_status
(
self
):
rec
=
self
.
api
.
update_proc_status
(
obs_id
=
'0000017'
,
status
=
3
,
)
print
(
'update_proc_status:'
,
rec
)
def
test_update_qc0_status
(
self
):
rec
=
self
.
api
.
update_qc0_status
(
obs_id
=
'0000017'
,
status
=
3
,
)
print
(
'update_qc0_status:'
,
rec
)
tests/test_facility_detector.py
→
tests/
facility/
test_facility_detector.py
View file @
d41f24f8
File moved
Prev
1
2
Next
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