Skip to content

Commit

Permalink
Issue 189: redo shelf to shelve (#193)
Browse files Browse the repository at this point in the history
* rewriting shelf

Changed a bunch of names (not all) from shelf to shelve while doing the rewrite just to make it match. It makes it much nicer in understanding the mapping of databases.

Cleaned up post2shelve to use the new shelve tables that account for versions.

Still had a bit of shelf laying about that testing found. Cleaned it up and changed some of the test harness to fit the new shelve.

The bulk of the changes came when the unit tests started running. It was here that most of the type changes and the whole concept of the db changes worked itself out.
  • Loading branch information
al-niessner authored May 3, 2023
1 parent 3f55e91 commit 0041df5
Show file tree
Hide file tree
Showing 140 changed files with 2,029 additions and 1,366 deletions.
2 changes: 1 addition & 1 deletion .ci/Dockerfile.ap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile.cit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile.dit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile.os
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/check_01.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/check_02.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/check_03.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/check_04.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
8 changes: 4 additions & 4 deletions .ci/check_05.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down Expand Up @@ -48,11 +48,11 @@ post_state "$context" "$description" "$state"

if current_state
then
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -it niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/ae --ae-pkg=ae --verbose | tee compliant.rpt.txt
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -t niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/ae --ae-pkg=ae --verbose | tee compliant.rpt.txt
[[ $? -eq 0 ]] && ret_ae=passed || ret_ae=failed
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -it niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/bae --ae-pkg=bae --verbose | tee -a compliant.rpt.txt
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -t niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/bae --ae-pkg=bae --verbose | tee -a compliant.rpt.txt
[[ $? -ne 0 ]] && ret_bae=passed || ret_bae=failed
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -it niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/Integration/ae --ae-pkg=ae --verbose | tee -a compliant.rpt.txt
docker run --rm -e PYTHONPATH=${rootdir}/Python -e USERNAME="$(whoami)" -v ${rootdir}:${rootdir} -u $UID -w ${rootdir} -t niessner/cit:$(cit_version) python3 -m dawgie.tools.compliant --ae-dir=${rootdir}/Test/Integration/ae --ae-pkg=ae --verbose | tee -a compliant.rpt.txt
[[ $? -eq 0 ]] && ret_iae=passed || ret_iae=failed

if [[ $ret_ae == "passed" ]] && [[ $ret_bae == "passed" ]] && [[ $ret_iae == "passed" ]]
Expand Down
2 changes: 1 addition & 1 deletion .ci/exercise_00.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/exercise_01.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/pypi.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/release_notes.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /bin/bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/step_00.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/step_99.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# need to signal the parent Jenkins script of failure if any step fails

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion .ci/util.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Bash/crew.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Bash/sdppiped.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Bash/worker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Python/Coda/aws_lambda.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Python/Coda/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# COPYRIGHT:
# Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
# Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
# U.S. Government sponsorship acknowledged.
#
# All rights reserved.
Expand Down
27 changes: 26 additions & 1 deletion Python/dawgie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
--
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down Expand Up @@ -256,6 +256,31 @@ class Version:
self._get_ver() and self._set_ver(). However, this should be done with
extreme caution.
'''
def __eq__(self, other):
return all ([self.design() == other.design(),
self.implementation() == other.implementation(),
self.bugfix() == other.bugfix()])
def __ge__(self, other):
if self.design() > other.design(): return True
if self.design() == other.design():
if self.implementation() > other.implementation(): return True
if self.implementation() == other.implementation():
return self.bugfix() >= other.bugfix()
return False
def __gt__(self, other): return self.__ge__ (other) and self.__ne__ (other)
def __le__(self, other):
if self.design() < other.design(): return True
if self.design() == other.design():
if self.implementation() < other.implementation(): return True
if self.implementation() == other.implementation():
return self.bugfix() <= other.bugfix()
return False
def __lt__(self, other): return self.__le__ (other) and self.__ne__ (other)
def __ne__(self, other):
return any ([self.design() != other.design(),
self.implementation() != other.implementation(),
self.bugfix() != other.bugfix()])

def _get_ver(self)->VERSION: return self._version_
def _set_ver(self, ver:VERSION): self._version_ = ver
def asstring(self)->str: return '.'.join ([str(self.design()),
Expand Down
12 changes: 6 additions & 6 deletions Python/dawgie/context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
--
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down Expand Up @@ -57,7 +57,7 @@ class PortOffset(enum.Enum):
farm = 1
frontend = 0
log = 2
shelf = 3
shelve = 3
pass

ae_base_path = os.environ.get ('DAWGIE_AE_BASE_PATH', '/proj/src/ae')
Expand All @@ -77,14 +77,14 @@ class PortOffset(enum.Enum):
data_stg = os.environ.get ('DAWGIE_DATA_STAGED', '/proj/data/stg')

db_host = os.environ.get ('DAWGIE_DB_HOST', 'localhost')
db_impl = os.environ.get ('DAWGIE_DB_IMPL', 'shelf')
db_impl = os.environ.get ('DAWGIE_DB_IMPL', 'shelve')
db_name = os.environ.get ('DAWGIE_DB_NAME', 'undefined')
db_path = os.environ.get ('DAWGIE_DB_PATH', '/proj/data/db')
db_post2shelve_prefix = os.environ.get ('DAWGIE_DB_POST2SHELVE_PREFIX',
'undefined')
db_rotate_path = os.environ.get ('DAWGIE_DB_ROTATE_PATH', '/proj/data/db')
db_copy_path = os.environ.get ('DAWGIE_DB_COPY_PATH', '/tmp')
db_port = int(os.environ.get ('DAWGIE_DB_PORT', 8080 + PortOffset.shelf.value))
db_port = int(os.environ.get ('DAWGIE_DB_PORT', 8080 + PortOffset.shelve.value))
db_rotate = os.environ.get('DAWGIE_DB_ROTATES', 10)
db_lock = False

Expand Down Expand Up @@ -231,15 +231,15 @@ def override (args):
pass

if args.context_db_impl == 'post':
if args.context_db_port == fe_port + PortOffset.shelf.value:
if args.context_db_port == fe_port + PortOffset.shelve.value:
args.context_db_port = 5432
pass
if args.context_db_path.find (':') < 0:
args.context_db_path = 'username:password'
pass
pass

if args.context_db_impl == 'shelf':
if args.context_db_impl == 'shelve':
# This db_path is the value before it is overriden
if args.context_db_rotate_path == db_path:
args.context_db_rotate_path = args.context_db_path
Expand Down
8 changes: 5 additions & 3 deletions Python/dawgie/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down Expand Up @@ -64,10 +64,12 @@ def _db_in_use():
m = importlib.import_module ('dawgie.db.' + dawgie.context.db_impl)
return m

def _prime_keys():
def _prime_keys()->[str]:
'''return all the kyes in the form runid.targetname.task.alg.sv.valname'''
return _db_in_use()._prime_keys()

def _prime_values():
def _prime_values()->[str]:
'''return all of the blob names'''
return _db_in_use()._prime_values()

def add (target_name:str)->bool:
Expand Down
2 changes: 1 addition & 1 deletion Python/dawgie/db/lockview.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down
4 changes: 2 additions & 2 deletions Python/dawgie/db/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
COPYRIGHT:
Copyright (c) 2015-2022, California Institute of Technology ("Caltech").
Copyright (c) 2015-2023, California Institute of Technology ("Caltech").
U.S. Government sponsorship acknowledged.
All rights reserved.
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def metrics()->'[dawgie.db.METRIC_DATA]':
try:
msv[vn] = dawgie.db.util.decode(row[7])
svs[key] = msv
except FileNotFoundError: log.error ('possible database corruption because cannot fine __metric__ state vector value: %s', row[7])
except FileNotFoundError: log.error ('possible database corruption because cannot find __metric__ state vector value: %s', row[7])
pass
for key,msv in svs.items():
cur.execute ('SELECT name FROM Target where PK = %s;', (key[2],))
Expand Down
Loading

0 comments on commit 0041df5

Please sign in to comment.