Commit 235f6f92 authored by M. Huang's avatar M. Huang
Browse files

documentation, example, readme update; Finetime from str fix

parent e4d3dfa7
......@@ -33,7 +33,7 @@ or from git repo:
python3 -m pip install http://mercury.bao.ac.cn:9006/mh/fdi/-/archive/master/fdi-master.tar.gz
If you want to install the ``develop`` and server dependencies:
If you want to install the ``develop`` dependencies:
.. code-block:: shell
......@@ -147,7 +147,7 @@ in another window run:
make testpns
To test your ``httppool`` servers installation, in one window, run:
To test your ``httppool`` servers installation, make sure to stop other server such as ``pnsserver`` above, then in one window, run:
.. code-block:: shell
......
docs/sphinx/_static/packages_pns.png

21.7 KB | W: | H:

docs/sphinx/_static/packages_pns.png

22.1 KB | W: | H:

docs/sphinx/_static/packages_pns.png
docs/sphinx/_static/packages_pns.png
docs/sphinx/_static/packages_pns.png
docs/sphinx/_static/packages_pns.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -281,6 +281,14 @@ fdi.dataset.tabledataset module
:undoc-members:
:show-inheritance:
fdi.dataset.tabledataset\_datamodel module
------------------------------------------
.. automodule:: fdi.dataset.tabledataset_datamodel
:members:
:undoc-members:
:show-inheritance:
fdi.dataset.testproducts module
-------------------------------
......
......@@ -17,6 +17,14 @@ Subpackages
Submodules
----------
fdi.pns.config module
---------------------
.. automodule:: fdi.pns.config
:members:
:undoc-members:
:show-inheritance:
fdi.pns.fdi\_requests module
----------------------------
......@@ -57,14 +65,6 @@ fdi.pns.pns\_server module
:undoc-members:
:show-inheritance:
fdi.pns.pnsconfig module
------------------------
.. automodule:: fdi.pns.pnsconfig
:members:
:undoc-members:
:show-inheritance:
fdi.pns.runflaskserver module
-----------------------------
......
......@@ -49,6 +49,14 @@ fdi.utils.getconfig module
:undoc-members:
:show-inheritance:
fdi.utils.leapseconds module
----------------------------
.. automodule:: fdi.utils.leapseconds
:members:
:undoc-members:
:show-inheritance:
fdi.utils.loadfiles module
--------------------------
......
This diff is collapsed.
__version_info__ = (1, 6, 3)
__version_info__ = (1, 6, 4)
__version__ = '.'.join(map(str, __version_info__))
......@@ -87,14 +87,23 @@ class FineTime(Copyable, DeepEqual, Serializable):
d = time
setTai = self.datetimeToFineTime(d)
elif issubclass(time.__class__, str):
t = time.strip()
try:
t = time.strip()
d = datetime.datetime.strptime(time, self.format)
d = datetime.datetime.strptime(t, self.format)
except ValueError:
tz = self.format[-3:]
if not t.endswith(tz):
logger.warning('Time zone %s assumed for %s', tz, t)
d = datetime.datetime.strptime(t + ' ' + tz, self.format)
if self.format[-4] == ' ':
# the last three letters are tz
tz = self.format[-3:]
if not t.endswith(tz):
logger.warning('Time zone %s assumed for %s', tz, t)
d = datetime.datetime.strptime(
t + ' ' + tz, self.format)
else:
# format does not have tz
logger.warning(
'Time zone stripped for %s according to format.' % t)
d = datetime.datetime.strptime(
t.rsplit(' ', 1)[0], self.format)
d1 = d.replace(tzinfo=datetime.timezone.utc)
setTai = self.datetimeToFineTime(d1)
else:
......
......@@ -12,7 +12,7 @@ You can copy the code from code blocks by clicking the ``copy`` icon on the top-
"""
# Import these packages needed in the tutorial
from fdi.dataset.product import Product
from fdi.dataset.product import Product, BaseProduct
from fdi.dataset.metadata import Parameter, MetaData
from fdi.dataset.numericparameter import NumericParameter
from fdi.dataset.stringparameter import StringParameter
......@@ -52,6 +52,7 @@ ArrayDataset -- sequence of data in the same unit and format
a1 = [1, 4.4, 5.4E3, -22, 0xa2]
v = ArrayDataset(a1)
# Show it. This is the same as print(v) in a non-interactive environment.
# "Default Meta." means the metadata settings are all default values..
v
# Create an ArrayDataset with some built-in properties set.
......@@ -412,13 +413,14 @@ This section shows how to store a product in a "pool" and get a reference back.
logger = logging.getLogger('')
logger.setLevel(logging.WARNING)
# a pool (LocalPool) for demonstration will be create here
demopoolpath = '/tmp/demopool_' + getpass.getuser()
demopoolname = 'demopool_' + getpass.getuser()
demopoolpath = '/tmp/' + demopoolname
demopoolurl = 'file://' + demopoolpath
# clean possible data left from previous runs
os.system('rm -rf ' + demopoolpath)
if PoolManager.isLoaded(DEFAULT_MEM_POOL):
PoolManager.getPool(DEFAULT_MEM_POOL).removeAll()
PoolManager.removeAll()
PoolManager.getPool(demopoolname, demopoolurl).removeAll()
# create a prooduct and save it to a pool
x = Product(description='save me in store')
......@@ -511,19 +513,21 @@ A :class:`ProductStorage` with pools attached can be queried with tags, properti
""")
# clean possible data left from previous runs
defaultpoolpath = '/tmp/fdi_pool_' + __name__ + getpass.getuser()
newpoolname = 'fdi_newpool_' + __name__ + getpass.getuser()
poolname = 'fdi_pool_' + getpass.getuser()
poolpath = '/tmp/' + poolname
newpoolname = 'fdi_newpool_' + getpass.getuser()
newpoolpath = '/tmp/' + newpoolname
os.system('rm -rf ' + defaultpoolpath)
os.system('rm -rf ' + poolpath)
os.system('rm -rf ' + newpoolpath)
poolurl = 'file://' + poolpath
newpoolurl = 'file://' + newpoolpath
if PoolManager.isLoaded(DEFAULT_MEM_POOL):
PoolManager.getPool(DEFAULT_MEM_POOL).removeAll()
PoolManager.removeAll()
PoolManager.getPool(poolname, poolurl).removeAll()
PoolManager.getPool(newpoolname, newpoolurl).removeAll()
# make a productStorage
defaultpoolurl = 'file://'+defaultpoolpath
pstore = ProductStorage(poolurl=defaultpoolurl)
pstore = ProductStorage(poolurl=poolurl)
# make another
newpoolurl = 'file://' + newpoolpath
pstore2 = ProductStorage(poolurl=newpoolurl)
# add some products to both storages. The product properties are different.
......@@ -562,11 +566,11 @@ len(pstore.getPools()) # == 2
# make a query on product metadata, which is the variable 'm'
# in the query expression, i.e. ``m = product.meta; ...``
# But '5000 < m["extra"]' does not work. see tests/test.py.
q = MetaQuery(Product, 'm["extra"] > 5001 and m["extra"] <= 5005')
q = MetaQuery(Product, 'm["extra"] > 5000 and m["extra"] <= 5005')
# search all pools registered on pstore
res = pstore.select(q)
# we expect [#2, #3, #4, #5]
len(res) # == 4
# we expect [#2, #3] Contex is not a subclass of Product, which is being searched
len(res) # == 2
# see
[r.product.description for r in res]
......@@ -577,17 +581,17 @@ len(res) # == 4
def t(m):
# query is a function
import re
# 'creator' matches the regex pattern
# 'creator' matches the regex pattern: 'n' + ? + '1'
return re.match('.*n.1.*', m['creator'].value)
q = MetaQuery(Product, t)
q = MetaQuery(BaseProduct, t)
res = pstore.select(q)
# expecting [3,4]
[r.product.creator for r in res]
# same as above but query is on the product. this is slow.
q = AbstractQuery(Product, 'p', '"n 1" in p.creator')
q = AbstractQuery(BaseProduct, 'p', '"n 1" in p.creator')
res = pstore.select(q)
# [3,4]
[r.product.creator for r in res]
......@@ -2121,7 +2121,9 @@ def test_FineTime():
# at TAI = 1, UTC ...
v = FineTime(1)
assert v.toDatetime().microsecond == 1
# from string
v = FineTime('1990-09-09T12:34:56.789098 UTC')
print(v)
# comparison
v1 = FineTime(12345678901234)
v2 = FineTime(12345678901234)
......
Markdown is supported
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