Esempio n. 1
0
 def make_command_line(argstring=None):
     if argstring:
         args, _ = parse_command_args().parse_known_args(argstring.split())
     else:
         args, _ = parse_command_args().parse_known_args()
     commands = []
     for arg, value in vars(args).items():
         if value:
             if value is True:
                 cmd_list = ["--{}".format(arg)]
             else:
                 cmd_list = ["--{}".format(arg), str(value)]
             commands.extend(cmd_list)
     return commands
Esempio n. 2
0
def entry_point():
    # parse command-line args
    args, _ = parse_command_args().parse_known_args()

    # set process title
    if args.title is not None:
        setproctitle.setproctitle(args.title)
    else:
        setproctitle.setproctitle('i-{}'.format(args.beamline))

    command = make_mpi_command_line(args)
    # run mpi
    print(" ".join(command))
    if not args.dry_run:
        start = time.time()
        try:
            if args.time:
                callback = get_total_time
            else:
                callback = None
            result = procrunner.run(command,
                                    callback_stdout=callback,
                                    working_directory=os.curdir)
        except KeyboardInterrupt:
            curdir = os.path.abspath(os.curdir)
            temp_files = [
                f for f in os.listdir(curdir)
                if os.path.splitext(f)[-1] == ".stream"
            ]
            for tfile in temp_files:
                tpath = os.path.join(curdir, tfile)
                os.remove(tpath)

            print("\n*** Terminated with KeyboardInterrupt")
            if args.time and times:
                print("*** Total processing time: {:.2f} sec".format(
                    times[-1]))
                print("*** Rate ({} images): {:.2f} Hz".format(
                    len(times),
                    len(times) / times[-1]))
            print("*** Total runtime: {:.2f} sec".format(time.time() - start))
            print("\n~~~ fin ~~~")
Esempio n. 3
0
def proc_for_testing():
    argstring = '-b test'.split()
    test_args, _ = parse_command_args().parse_known_args(argstring)
    reader = MinimalReader(args=test_args)
    return reader.processor
Esempio n. 4
0
def imported_data():
    argstring = '-b test'.split()
    test_args, _ = parse_command_args().parse_known_args(argstring)
    reader = MinimalReader(args=test_args)
    return reader.run()
Esempio n. 5
0
from __future__ import absolute_import, division, print_function
"""
Author      : Lyubimov, A.Y.
Created     : 04/20/2020
Last Changed: 05/15/2020
Description : pytest fixtures for data importing and processing
"""

import os
import shutil
import pytest

from interceptor import packagefinder
from interceptor.connector.connector import Reader, Collector
from interceptor.command_line.connector_run import parse_command_args
args, _ = parse_command_args().parse_known_args()


class MinimalReader(Reader):
    def __init__(self, name='test', args=None):
        super(MinimalReader, self).__init__(name=name, args=args)

    def make_frames(self):
        self.frames = []
        img_dir = packagefinder('images', 'test', module='interceptor')
        for n in range(6):
            filename = 'zmq_000001_{:02d}.zmq'.format(n + 1)
            filepath = os.path.join(img_dir, filename)
            with open(filepath, 'rb') as fh:
                self.frames.append(fh.read())
Esempio n. 6
0
 def make_mpi_command_line(argstring):
     args, _ = parse_command_args().parse_known_args(argstring.split())
     command = make_mpi_command_line(args)
     return command