Skip to content

Commit

Permalink
protcur test integration, fix sparc memfile naming
Browse files Browse the repository at this point in the history
  • Loading branch information
tgbugs committed Oct 30, 2019
1 parent 4997e48 commit 8e01d52
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 20 deletions.
21 changes: 12 additions & 9 deletions protcur/protcur/analysis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3.6
#!/usr/bin/env python3.7
"""Run protcur analaysis
Usage:
analysis [options]
protcur-analysis [options]
Options:
-s --sync sync
Expand All @@ -26,7 +26,10 @@
from hyputils.hypothesis import HypothesisAnnotation, HypothesisHelper, idFromShareLink
from protcur.core import linewrap, color_pda, log, logd
from protcur.config import __units_folder__ as units_folder
from IPython import embed
try:
breakpoint
except NameError:
from IPython import embed as breakpoint

sgv = Vocabulary(cache=True)
RFU = 'protc:references-for-use'
Expand Down Expand Up @@ -538,7 +541,7 @@ def _children_ids(self):
def children(self): # TODO various protc:implied- situations...
#if anyMembers(self.tags, *('protc:implied-' + s for s in ('input', 'output', 'aspect'))): # FIXME hardcoded fix
#if self.parent is None:
#embed()
#breakpoint()
#raise ValueError(f'protc:implied-* does not have a parrent? Did you mistag?')
if 'protc:aspect' in self.tags:
for reply in self.replies:
Expand Down Expand Up @@ -768,7 +771,7 @@ def _dispatch(self):
# it would seem that this happens sporadically because
# of the set ordering of tags
print('===========================================================')
embed()
breakpoint()
raise TypeError(f'Cannot dispatch on NoneType!\n{super()!r}')
else:
raise TypeError('Cannot dispatch on NoneType!\n'
Expand All @@ -787,7 +790,7 @@ def _dispatch(self):
# namespace into the current handler
return self.additional_namespaces[namespace](self).astValue
else:
embed()
breakpoint()
raise TypeError(f'{self.classn} does not dispatch on types from '
f'another namespace ({namespace}) ({self.tags}).')
dispatch_on = dispatch_on.replace('*', '').replace('-', '_')
Expand Down Expand Up @@ -881,7 +884,7 @@ def __gt__(self, other):
#return self.astType + self.astValue >= other.astType + other.astValue
return type_ + self.value >= oat + other.value
except TypeError as e:
embed()
breakpoint()
raise e

def __lt__(self, other):
Expand Down Expand Up @@ -1435,7 +1438,7 @@ def update():
if args['--sync']:
stream_thread.start() # need this to be here to catch deletes

embed()
breakpoint()
exit_loop()
if args['--sync']:
stream_thread.join()
Expand Down Expand Up @@ -1484,7 +1487,7 @@ def chebis(j):
#with open(os.path.expanduser('~/ni/nifstd/chebimissing_id_names2.txt'), 'wt') as f: f.write(pformat(ids_only))
#with open(os.path.expanduser('~/ni/nifstd/chebimissing_ids2.txt'), 'wt') as f: f.write('\n'.join(missing))

embed()
breakpoint()
# HOW DO I KILL THE STREAM LOOP!??! << answered, though quite a bit more complicated than expected

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion protcur/protcur/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def export(self):

def main():
from docopt import docopt, parse_defaults
args = docopt(__doc__, version='clifun-demo 0.0.0')
args = docopt(__doc__, version='protcur 0.0.0')
defaults = {o.name:o.value if o.argcount else None for o in parse_defaults(__doc__)}
options = Options(args, defaults)
main = Main(options)
Expand Down
2 changes: 1 addition & 1 deletion protcur/protcur/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# set hlog and plog to conform to pyontutils logging conventions
# note that this resets logd handler too since it is inherited
from hyputils.hypothesis import log as _hlog
from pysercomb.utils import log as _plog
_hlog.removeHandler(_hlog.handlers[0])
_hlog.addHandler(log.handlers[0])
from pysercomb.utils import log as _plog
_plog.removeHandler(_plog.handlers[0])
_plog.addHandler(log.handlers[0])

Expand Down
18 changes: 11 additions & 7 deletions protcur/protcur/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.6
#!/usr/bin/env python3.7
"""protcur development server
Usage:
protcur-server [options]
Expand Down Expand Up @@ -606,24 +606,28 @@ def main():
args = docopt(__doc__)
defaults = {o.name:o.value if o.argcount else None for o in parse_defaults(__doc__)}
port = int(args['--port'])
if args['--sparc']:
port = port if port != int(defaults['--port']) else None
return sparc_main(args, port)

comments = not args['--no-comment']

_, ghash = group_to_memfile(group).as_posix().rsplit('-', 1)
ghashshort = ghash[:10]

if args['--sparc']:
port = port if port != int(defaults['--port']) else None
memfile = f'{ucd}/protcur/sparc-{port}-{ghashshort}-server-annos.json'
return sparc_main(memfile, args, port)

app = make_server_app(f'{ucd}/protcur/protcur-{port}-{ghashshort}-server-annos.json', comments)
app.debug = False
app.run(host='localhost', port=port, threaded=True)
app.exit_loop()


def sparc_main(args=None, port=None):
def sparc_main(memfile, args=None, port=None):
if port is None:
port = 7001

from core import annoSync
get_annos, annos, stream_thread, exit_loop = annoSync('/tmp/sparc-server-annos.json',
get_annos, annos, stream_thread, exit_loop = annoSync(memfile,
#tags=('sparc:',),
helpers=(SparcMI,))
#stream_thread.start()
Expand Down
4 changes: 2 additions & 2 deletions protcur/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def find_version(filename):
'htmlfn',
'hyputils>=0.0.4',
'Markdown',
'pyontutils>=0.1.3',
'pysercomb',
'pyontutils>=0.1.4',
'pysercomb>=0.0.2',
],
extras_require={'dev':[],
'test': tests_require,
Expand Down
36 changes: 36 additions & 0 deletions protcur/test/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import unittest
from pathlib import Path
from pyontutils.utils import get_working_dir
from pyontutils.integration_test_helper import _TestScriptsBase, Folders, Repo
import protcur


class TestScripts(Folders, _TestScriptsBase):
""" woo! """


skip = ('app',)
ci_skip = tuple()

mains = {'analysis': ['protcur-analysis', '--help'],
'cli': ['protcur', '--help'],
'server': ['protcur-server', '--help'],
}

module_parent = Path(__file__).resolve().parent.parent
working_dir = get_working_dir(__file__)
if working_dir is None:
# python setup.py test will run from the module_parent folder
# I'm pretty the split was only implemented because I was trying
# to run all tests from the working_dir in one shot, but that has
# a number of problems with references to local vs installed packages
working_dir = module_parent

post_load = lambda : None
post_main = lambda : None

TestScripts.populate_tests(protcur, working_dir, mains,
skip=skip, ci_skip=ci_skip,
module_parent=module_parent,
post_load=post_load, post_main=post_main,
only=[], do_mains=True)

0 comments on commit 8e01d52

Please sign in to comment.