Ejemplo n.º 1
0
def process_uts_tests(testinfo, testfolder, handlers, reportfile):
    args = DataTree()
    args.experReportGraphs = testfolder.graphs
    args.experJson = testfolder.jsoncalc
    args.experJsonCalc = testfolder.jsoncalc
    args.only_first = False
    args.report = reportfile
    args.step = 2
    args.begin = 80.3
    args.end = 4.8

    data = DataTree()
    data.tests = DataTree()

    trackingtest = testfolder.raws.csv_step04_uts.tracking
    trackingdata = csvread(trackingtest.as_posix())
    data.tracking = trackingdata

    data.tests.uts = DataTree(tracking=trackingdata)
    # debug(testfolder.raws.csv_step02_precond.tracking)
    data.tests.preconds = DataTree(
        tracking=csvread(testfolder.raws.csv_step02_precond.tracking))
    data.datasheet = testfolder.datasheet

    data.details = Json.load_json_from(testfolder.details)

    return [
        handler(testinfo=testinfo,
                testfolder=testfolder,
                testdata=data,
                args=args) for handler in handlers
    ]

    measurements = run_image_measure.process_test(testinfo, testfolder)
Ejemplo n.º 2
0
def process_cycle_tests(testinfo, testfolder, reportfile, doLoad, handlers,):
    args = DataTree()
    args.experReportGraphs = testfolder.graphs
    args.experJson = testfolder.jsoncalc
    args.experJsonCalc = testfolder.jsoncalc
    args.only_first = False
    args.report = reportfile
    args.doLoad = doLoad
    
    testdata = TestData(tests=TestData())
    
    # debug(testfolder.raws.preconds_csv.tracking)
    testdata.tests.preconds = DataTree(tracking = csvread( testfolder.raws.preconds_csv.tracking ))    

    cycles_test = 'cycles_{}_csv'.format(testinfo.orientation)
    debug(cycles_test, testfolder.raws[cycles_test].tracking)
    testdata.tests.cycles = TestData()
    if doLoad.tracking:
        csvdata_tracking = csvread(testfolder.raws[cycles_test].tracking.as_posix())
        testdata.tests.cycles.tracking = csvdata_tracking
    if doLoad.trends:
        csvdata_trends = csvread(testfolder.raws[cycles_test].trends.as_posix())
        testdata.tests.cycles.trends = csvdata_trends

    testdata.details = Json.load_json_from(testfolder.details)
    
    results = []
    for handler in handlers:
        results.append( handler(testinfo=testinfo, testfolder=testfolder, testdata=testdata, args=args) )
        
    return results    
Ejemplo n.º 3
0
    def __init__(self, projdescpath, verify=True, project=None, ):
        projdescpath = Path(str(projdescpath)).resolve()
        
        if not projdescpath.exists():
            raise Exception(projdescpath)
            
        projdesc = Json.load_json_from(projdescpath)
        self.projdesc = projdesc
        
        for i in ["testinfo", "testfolder", "projectfolder"]:
            key = ("experiment_config",i)
            if not projdesc[key]:
                print('Missing:\n\n    File "{key}", line 1, in {projdescpath}\n\n'.format(projdescpath=projdescpath, key=("experiment_config",i)), file=sys.stdout)
                raise ValueError("Missing key in config: `{}` from: `{}`".format(key, projdescpath))
        
        self._testinfo = generatetestinfoclass(**projdesc["experiment_config"]["testinfo"])
        
        names = self.projdesc.experiment_config.name.split('|' if '|' in self.projdesc.experiment_config.name else ';')
        self.experiment_name = names[0]
        self.test_name = names[1:]

        self.project = projdescpath.parent if not project else project

        files = DataTree(projdesc.experiment_config["projectfolder"]["filestructure"])
        self._files = self.parsefolders(files, verify, parent=self.project)
        for name, file in self._files.items():
            self[name] = file
Ejemplo n.º 4
0
def process_test(testconf, args):
    
    if args.options['output','dataprocessor','skipreports']:
        print("Not running reports.")
        return
        
    origtestdetails = Json.load_json_from(testconf.folder.details)
    
    testdetails = mapd(origtestdetails, valuef=itemHandler)
    testdetails = mapd(testdetails, valuef=formatHandler)

    processReportConfig(testconf, args)
    
    testconf.data.summarydetails = testdetails
    testconf.data.flatdetails = DataTree(flatten(testdetails))
    
    jsonlfilename = "data (type=flat summary ; kind=json ; short={short} ; v{version}).jsonl"
    jsonlfilename = jsonlfilename.format(short=testconf.info.short, version=args.options["dataprocessor"]["version"])
    jsonlfilename = testconf.folder.main / jsonlfilename
    
    # with jsonlFilename.open('w') as jsonlfile:    
    Json.write_json_to(jsonlfilename, flatten(origtestdetails), indent=None)
    
    mdfile, reportStr = processTestDocument(testconf, args)

    
    if args.options["output", "generatepdfs"]:
        generatepdfs(mdfile)
    else:
        print("Not generating pdfs. ")
Ejemplo n.º 5
0
def process_method(methodname, method, testfolder, projdesc, state):
        
    files = DataTree()
    
    for methoditem in method:
        
        print(mdHeader(3, "Method Item: {} ".format(methoditem.name)))
        # ================================================
        debug(methoditem)
        
        
        testdetails = Json.load_json_from(testfolder.details)
        state.details = testdetails
        state.methoditem = methoditem
        # = Files =
        data = DataTree()
            
        # ====================
        # = Handle Processor =
        # ====================
        processorname = methoditem.processor['$ref'].lstrip('#/processors/')
        print(mdHeader(4, "Processor: {}".format(processorname)))
        processor = projdesc.processors[processorname]

        itemstate = state.set(methoditem=methoditem, methodname=methodname)
        push(itemstate, 'methoditem',methoditem.name)        
        debug(itemstate.position)
        itemstate.testfolder = testfolder
        process(testfolder=testfolder, data=data, processor=processor, state=itemstate)
Ejemplo n.º 6
0
def test_folder():

    import scilab.expers.configuration as config

    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "fatigue-failure|uts|expr1"
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|uts|trial1"
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|uts|trial3"

    pdp = parentdir / 'projdesc.json'
    print(pdp)
    print(pdp.resolve())

    fs = config.FileStructure(projdescpath=pdp, verify=True)
    # Test test images for now
    test_dir = fs.tests.resolve()
    testitemsd = fs.testitemsd()

    import shutil
    from tabulate import tabulate

    testitems = {
        k.name: DataTree(info=k, folder=v, data=DataTree())
        for k, v in testitemsd.items()
    }

    args = DataTree()
    args.version = "12"
    args.options = DataTree()
    args.options["output", "generatepdfs"] = True

    # args.testname = name
    # args.test = test
    # args.fs = fs

    for name, test in sorted(testitems.items())[:]:
        # if name not in ["nov24(gf9.2-lmm)-wf-lg-l4-x2"]:
        # continue

        print("\n")
        display(HTML("<h2>{} | {}</h2>".format(test.info.short, name)))

        folder = fs.testfolder(testinfo=test.info)

        # debug(mapd(flatten(folder), valuef=lambda x: type(x), keyf=lambda x: x))

        data = [(k, v.relative_to(parentdir),
                 "&#10003;" if v.exists() else "<em>&#10008;</em>")
                for k, v in flatten(folder).items()]
        data = sorted(data)

        display(
            HTML(tabulate(data, ["Name", "Folder", "Exists"],
                          tablefmt='html')))
        debug(folder.data.relative_to(parentdir))

        test.folder = folder
        test.projectfolder = fs
        test.details = Json.load_json_from(folder.details)

        run(test, args)
Ejemplo n.º 7
0
def process_uts_tests(testinfo, testfolder, handlers, reportfile):
    args = DataTree()
    args.experReportGraphs = testfolder.graphs
    args.experJson = testfolder.jsoncalc
    args.experJsonCalc = testfolder.jsoncalc
    args.only_first = False
    args.report = reportfile    
    args.step = 2
    args.begin = 80.3
    args.end = 4.8
    
    data = DataTree()
    data.tests = DataTree()
    
    trackingtest = testfolder.raws.csv_step04_uts.tracking
    trackingdata = csvread(trackingtest.as_posix())
    data.tracking = trackingdata
    
    data.tests.uts = DataTree(tracking=trackingdata)
    # debug(testfolder.raws.csv_step02_precond.tracking)
    data.tests.preconds = DataTree(tracking = csvread( testfolder.raws.csv_step02_precond.tracking ))    
    data.datasheet = testfolder.datasheet
    
    data.details = Json.load_json_from(testfolder.details)
    
    return [ handler(testinfo=testinfo, testfolder=testfolder, testdata=data, args=args)
                for handler in handlers ]

    measurements = run_image_measure.process_test(testinfo, testfolder)
Ejemplo n.º 8
0
        def test_print_headers():

            project_description_url = Path(__file__).parent / "project_description.json"
            debug(project_description_url)
            project_description_url = project_description_url.resolve()    
            project_description = Json.load_json_from(project_description_url)
            
            json_to_excel(project_description)
Ejemplo n.º 9
0
    def setprojdir(self, testdir):
        
        debug(testdir)
        
        def showErrorMessage(errmsg, dir, ex=None):
            errorfmt = "Invalid project:<br>Dir `{1}`<br>Error `{0}`"
            if ex: 
                errorfmt += "<br>Exception:<br><pre><code>{ex}</code></pre>"
            errorMessageDialog = QErrorMessage(self._parent)
            errorMessageDialog.showMessage(errorfmt.format(errmsg, dir, ex=ex))
        
        projectdir = Path(str(testdir))
        
        if not projectdir.exists():
            showErrorMessage("Project folder does not exist.", testdir)
            return
        
        projdescpath = projectdir / "projdesc.json"
        
        if not projdescpath.exists():
            showErrorMessage(" Missing projectdesc file.", str(projectdir))
            return
        else:
            try:
                projdescpath.resolve()
                self.projectdesc = Json.load_json_from(str(projdescpath))
            except Exception as err:
                logging.exception(err)
                showErrorMessage("Error loading project description: ", testdir, ex=traceback.format_exc())
                return
        
        try:
            self.projectdir = projectdir
            self.fs = config.FileStructure(projdescpath=projdescpath,verify=True)
        
            self.test_dir = self.fs.tests.resolve()
            self.testitemsd = self.fs.testitemsd()
            self.args = DataTree()

            self.args = DataTree()
            self.args.options = self.defaultoptions()
            
            print("Setting args: ", self.args)
            
            # = Emit projectdirchanged =
            print("Setting test directory:", self.test_dir)
            self.projectdirchanged.emit(str(projectdir))
            self.projectrefresh.emit()
            
        except Exception as err:
            traceback.print_exc(file=sys.stderr)
            
            # ei = boltons.tbutils.ExceptionInfo.from_current()
            # raise err
            
            showErrorMessage("Error setting project: ", testdir, ex=traceback.format_exc())
            return
Ejemplo n.º 10
0
def test_folder():
    
    import scilab.expers.configuration as config
    
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "fatigue-failure|uts|expr1"
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|uts|trial1"
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|uts|trial3"
    
    pdp = parentdir / 'projdesc.json' 
    print(pdp)
    print(pdp.resolve())
    
    fs = config.FileStructure(projdescpath=pdp, verify=True)
    # Test test images for now
    test_dir = fs.tests.resolve()
    testitemsd = fs.testitemsd()
    
    import shutil
    from tabulate import tabulate

    testitems = { k.name: DataTree(info=k, folder=v, data=DataTree() ) for k,v in testitemsd.items()}

    args = DataTree()
    args.version = "12"
    args.options = DataTree()
    args.options["output", "generatepdfs"] = True
    
    # args.testname = name
    # args.test = test
    # args.fs = fs
    
    for name, test in sorted( testitems.items() )[:]:
        # if name not in ["nov24(gf9.2-lmm)-wf-lg-l4-x2"]:
            # continue
        
        print("\n")
        display(HTML("<h2>{} | {}</h2>".format(test.info.short, name)))
    
        folder = fs.testfolder(testinfo=test.info)
        
        # debug(mapd(flatten(folder), valuef=lambda x: type(x), keyf=lambda x: x))
        
        data = [ (k,v.relative_to(parentdir), "&#10003;" if v.exists() else "<em>&#10008;</em>" ) 
                    for k,v in flatten(folder).items() ]
        data = sorted(data)
        
        display(HTML(tabulate( data, [ "Name", "Folder", "Exists" ], tablefmt ='html' )))
        debug(folder.data.relative_to(parentdir))
        
        test.folder = folder
        test.projectfolder = fs
        test.details = Json.load_json_from(folder.details)
        
        run(test, args)
Ejemplo n.º 11
0
def execute(fs, name, testconf, args):

    print("\n")
    display(
        HTML("<h2>Processing Test: {} | {}</h2>".format(
            testconf.info.short, name)))

    folder = fs.testfolder(testinfo=testconf.info)

    try:
        processed_link = fs.processed / testconf.info.short
        if not processed_link.exists():
            debug("../" + str(folder.testdir.relative_to(fs.project)),
                  str(processed_link))
            os.symlink("../" + str(folder.testdir.relative_to(fs.project)),
                       str(processed_link),
                       target_is_directory=True)
    except Exception as err:
        logging.warn("Unable to link processed dir: " + str(err))

    data = [(k, v.relative_to(args.parentdir),
             "&#10003;" if v.exists() else "<em>&#10008;</em>")
            for k, v in flatten(folder).items() if v]
    data = sorted(data)

    print()
    print(
        HTML(tabulate(data, ["Name", "Folder", "Exists"], tablefmt='pipe'),
             whitespace="pre-wrap"))
    debug(folder.data.relative_to(args.parentdir))

    args.testname = name
    args.testconf = testconf
    args.report = sys.stdout

    testconf.folder = folder

    # Setup Arguments Environment
    state = DataTree()
    state.args = args
    state.filestructure = fs
    state.position = []

    # update json details
    print(mdHeader(2, "Load JSON Data"))

    testdetails = Json.load_json_from(testfolder.details)
    state.details = testdetails

    print(mdHeader(2, "Update Reports"))

    results = process(testconf=testconf, state=state, args=args)

    return results
Ejemplo n.º 12
0
def execute(fs, name, testconf, args):
    
    print("\n")
    display(HTML("<h2>Processing Test: {} | {}</h2>".format(testconf.info.short, name)))
    
    folder = fs.testfolder(testinfo=testconf.info)
    
    try:
        processed_link = fs.processed / testconf.info.short 
        if not processed_link.exists():
            debug("../"+str(folder.testdir.relative_to(fs.project)), str(processed_link))
            os.symlink("../"+str(folder.testdir.relative_to(fs.project)), str(processed_link), target_is_directory=True )
    except Exception as err:
        logging.warn("Unable to link processed dir: "+str(err))
    
    data = [ (k,v.relative_to(args.parentdir), "&#10003;" if v.exists() else "<em>&#10008;</em>" ) 
                for k,v in flatten(folder).items() if v ]
    data = sorted(data)

    print()
    print(HTML(tabulate( data, [ "Name", "Folder", "Exists" ], tablefmt ='pipe' ), whitespace="pre-wrap"))
    debug(folder.data.relative_to(args.parentdir))
    
    args.testname = name
    args.testconf = testconf
    args.report = sys.stdout
    
    testconf.folder = folder
    
    # Setup Arguments Environment
    state = DataTree()
    state.args = args
    state.filestructure = fs
    state.position = []
    
    # update json details
    print(mdHeader(2, "Load JSON Data"))
    
    testdetails = Json.load_json_from(testfolder.details)
    state.details = testdetails
    
    print(mdHeader(2, "Update Reports"))

    results = process(testconf=testconf, state=state, args=args)

    return results
Ejemplo n.º 13
0
def process_cycle_tests(
    testinfo,
    testfolder,
    reportfile,
    doLoad,
    handlers,
):
    args = DataTree()
    args.experReportGraphs = testfolder.graphs
    args.experJson = testfolder.jsoncalc
    args.experJsonCalc = testfolder.jsoncalc
    args.only_first = False
    args.report = reportfile
    args.doLoad = doLoad

    testdata = TestData(tests=TestData())

    # debug(testfolder.raws.preconds_csv.tracking)
    testdata.tests.preconds = DataTree(
        tracking=csvread(testfolder.raws.preconds_csv.tracking))

    cycles_test = 'cycles_{}_csv'.format(testinfo.orientation)
    debug(cycles_test, testfolder.raws[cycles_test].tracking)
    testdata.tests.cycles = TestData()
    if doLoad.tracking:
        csvdata_tracking = csvread(
            testfolder.raws[cycles_test].tracking.as_posix())
        testdata.tests.cycles.tracking = csvdata_tracking
    if doLoad.trends:
        csvdata_trends = csvread(
            testfolder.raws[cycles_test].trends.as_posix())
        testdata.tests.cycles.trends = csvdata_trends

    testdata.details = Json.load_json_from(testfolder.details)

    results = []
    for handler in handlers:
        results.append(
            handler(testinfo=testinfo,
                    testfolder=testfolder,
                    testdata=testdata,
                    args=args))

    return results
Ejemplo n.º 14
0
    def __init__(
        self,
        projdescpath,
        verify=True,
        project=None,
    ):
        projdescpath = Path(str(projdescpath)).resolve()

        if not projdescpath.exists():
            raise Exception(projdescpath)

        projdesc = Json.load_json_from(projdescpath)
        self.projdesc = projdesc

        for i in ["testinfo", "testfolder", "projectfolder"]:
            key = ("experiment_config", i)
            if not projdesc[key]:
                print(
                    'Missing:\n\n    File "{key}", line 1, in {projdescpath}\n\n'
                    .format(projdescpath=projdescpath,
                            key=("experiment_config", i)),
                    file=sys.stdout)
                raise ValueError(
                    "Missing key in config: `{}` from: `{}`".format(
                        key, projdescpath))

        self._testinfo = generatetestinfoclass(
            **projdesc["experiment_config"]["testinfo"])

        names = self.projdesc.experiment_config.name.split(
            '|' if '|' in self.projdesc.experiment_config.name else ';')
        self.experiment_name = names[0]
        self.test_name = names[1:]

        self.project = projdescpath.parent if not project else project

        files = DataTree(
            projdesc.experiment_config["projectfolder"]["filestructure"])
        self._files = self.parsefolders(files, verify, parent=self.project)
        for name, file in self._files.items():
            self[name] = file
Ejemplo n.º 15
0
def execute(fs, name, testconf, args):
    
    print("\n")
    display(HTML("<h2>Processing Test: {} | {}</h2>".format(testconf.info.short, name)))
    
    folder = fs.testfolder(testinfo=testconf.info)
    
    try:
        processed_link = fs.processed / testconf.info.short 
        if not processed_link.exists():
            debug("../"+str(folder.testdir.relative_to(fs.project)), str(processed_link))
            os.symlink("../"+str(folder.testdir.relative_to(fs.project)), str(processed_link), target_is_directory=True )
    except Exception as err:
        print("Unable to link processed dir: "+str(err))
    
    #data = [ (k,v.relative_to(fs.project), "&#10003;" if v.exists() else "<em>&#10008;</em>" ) 
    #            for k,v in flatten(folder).items() if v ]
    #data = sorted(data)

    #print()
    #print(HTML(tabulate( data, [ "Name", "Folder", "Exists" ], tablefmt ='pipe' ), whitespace="pre-wrap"))
    #debug(folder.data.relative_to(fs.project))
    
    args.testname = name
    args.testconf = testconf
    args.report = sys.stdout
    
    testconf.folder = folder
    testconf.projectfolder = fs
    
    # Setup Arguments Environment
    state = DataTree()
    state.args = args
    state.filestructure = fs
    state.position = []
    
    debug(args.options)
    
    # update json details
    if args.options["dataprocessor", "exec", "imageMeasurement"]:
        print(mdHeader(2, "Run Image Measurement"))
    
        imageconfstate = state.set(image_measurement=fs.projdesc["experiment_config","config","calibration","image_measurement"])
        processimagemeasurement.process_test(testconf, state=imageconfstate, args=args)
        # run_image_measure.process_test(testconf.info, testconf.folder)
    
    if args.options["dataprocessor", "exec", "datasheetparser"]:
        print(mdHeader(2, "Make JSON Data"))
    
        datasheetparser.handler(testconf=testconf, excelfile=folder.datasheet, args=args)
        merge_calculated_jsons.handler(testinfo=testconf.info, testfolder=testconf.folder, args=args, savePrevious=False)
    
    if args.options["dataprocessor", "exec", "processMethods"]:
    
        print(mdHeader(2, "Executing"))
    
        process_methods(folder, state, args)

    
    if args.options["dataprocessor", "exec", "mergeJsonCalcPost"]:
        print(mdHeader(2, "Merging JSON Data"))
        merge_calculated_jsons.handler(testinfo=testconf.info, testfolder=testconf.folder, args=args, savePrevious=False)

    if args.options["dataprocessor", "exec", "graphs"]:
        testconf.details = Json.load_json_from(testconf.folder.details)
        print(mdHeader(2, "Running Graphs"))
        expertype = fs.projdesc["experiment_config"]["type"]
        if expertype == "cycles":
            print(mdHeader(3, "Cycles Graphs"))
            cycles_graph_runner.run(test=testconf, args=args)
        else:
            print(mdHeader(3, "UTS Graphs"))
            uts_graph_runner.run(test=testconf, args=args)

    if args.options["dataprocessor", "exec", "generateReports"]:
        print(mdHeader(2, "Generating Report and summary data"))
        testconf.details = Json.load_json_from(testconf.folder.details)

        processingreports.process_test(testconf=testconf, args=args)
Ejemplo n.º 16
0
    def load(self, name='details'):

        data = Json.load_json_from(testfolder.self[name])

        return data
Ejemplo n.º 17
0
def test_folder():

    import scilab.expers.configuration as config
    import scilab.expers.mechanical.fatigue.cycles as exper

    args = DataTree()
    args.version = "0"
    args.options = DataTree()
    args.options["output", "generatepdfs"] = True

    # args.testname = name
    # args.test = test
    # args.fs = fs

    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "fatigue-failure|uts|expr1"
    # args.parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|cycles|trial1"
    args.parentdir = Path(os.path.expanduser(
        "~/proj/phd-research/")) / "exper;fatigue-failure;cycles;trial2"

    pdp = args.parentdir / 'projdesc.json'
    print(pdp)
    print(pdp.resolve())

    fs = config.FileStructure(projdescpath=pdp,
                              verify=True,
                              project=args.parentdir)
    # Test test images for now
    test_dir = fs.tests.resolve()
    testitemsd = fs.testitemsd()

    import shutil
    from tabulate import tabulate

    testitems = {
        k.name: DataTree(info=k, folder=v, data=DataTree())
        for k, v in testitemsd.items()
    }

    summaries = OrderedDict()

    for name, test in sorted(testitems.items())[:]:
        # if name not in ["jan11(gf11.5-llm)-wa-lg-l6-x1"]:
        # continue
        # if name not in ["jan11(gf11.5-llm)-wa-lg-l6-x1"]:
        # continue

        print("\n")
        display(HTML("<h2>{} | {}</h2>".format(test.info.short, name)))

        folder = fs.testfolder(testinfo=test.info)

        #     debug(mapd(flatten(folder), valuef=lambda x: type(x), keyf=lambda x: x))

        data = [(k, v.relative_to(args.parentdir),
                 "&#10003;" if v.exists() else "<em>&#10008;</em>")
                for k, v in flatten(folder).items()]
        data = sorted(data)

        display(
            HTML(tabulate(data, ["Name", "Folder", "Exists"],
                          tablefmt='html')))
        debug(folder.data.relative_to(args.parentdir))

        test.folder = folder
        test.projectfolder = fs
        test.details = Json.load_json_from(folder.details)

        try:
            run(test, args)
            summaries[name] = "Success", "", ""
        except Exception as err:
            # summaries[name] = "Failed"
            summaries[name] = "Failed", str(
                err), "<a src='file://{}'>Folder</a>".format(
                    test.folder.testdir.as_posix())
            logging.exception(err)
            # raise err

    print("Summaries:\n\n")
    print(
        HTML(tabulate([(k, ) + v for k, v in summaries.items()],
                      ["Test Name", "Status", "Error", "Folder"],
                      tablefmt='pipe'),
             whitespace="pre-wrap"))
    print()
Ejemplo n.º 18
0
def load_project_description(testfolder):
    ## temporary, later lookup test config
    project_description = Json.load_json_from(
        testfolder.projectdescription.resolve())
    return project_description
Ejemplo n.º 19
0
def load_columns_json(filepath):
    return Json.load_json_from(filepath)
Ejemplo n.º 20
0
def test_folder():
    
    import scilab.expers.configuration as config
    import scilab.expers.mechanical.fatigue.cycles as exper
    
    args = DataTree()
    args.version = "0"
    args.options = DataTree()
    args.options["output", "generatepdfs"] = True
    
    # args.testname = name
    # args.test = test
    # args.fs = fs
    
    # parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "fatigue-failure|uts|expr1"
    # args.parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper|fatigue-failure|cycles|trial1"
    args.parentdir = Path(os.path.expanduser("~/proj/phd-research/")) / "exper;fatigue-failure;cycles;trial2"
    
    pdp = args.parentdir / 'projdesc.json' 
    print(pdp)
    print(pdp.resolve())
    
    fs = config.FileStructure(projdescpath=pdp, verify=True, project=args.parentdir)
    # Test test images for now
    test_dir = fs.tests.resolve()
    testitemsd = fs.testitemsd()
    
    import shutil
    from tabulate import tabulate
    
    testitems = { k.name: DataTree(info=k, folder=v, data=DataTree() ) for k,v in testitemsd.items() }
    
    summaries = OrderedDict()
    
    for name, test in sorted( testitems.items() )[:]:
        # if name not in ["jan11(gf11.5-llm)-wa-lg-l6-x1"]:
            # continue
        # if name not in ["jan11(gf11.5-llm)-wa-lg-l6-x1"]:
            # continue
        
        print("\n")
        display(HTML("<h2>{} | {}</h2>".format(test.info.short, name)))
    
        folder = fs.testfolder(testinfo=test.info)
    
    #     debug(mapd(flatten(folder), valuef=lambda x: type(x), keyf=lambda x: x))
        
        data = [ (k,v.relative_to(args.parentdir), "&#10003;" if v.exists() else "<em>&#10008;</em>" ) 
                    for k,v in flatten(folder).items() ]
        data = sorted(data)
    
        display(HTML(tabulate( data, [ "Name", "Folder", "Exists" ], tablefmt ='html' )))
        debug(folder.data.relative_to(args.parentdir))
        
        test.folder = folder
        test.projectfolder = fs
        test.details = Json.load_json_from(folder.details)
        
        try:
            run(test, args)
            summaries[name] = "Success", "", ""
        except Exception as err:
            # summaries[name] = "Failed"
            summaries[name] = "Failed", str(err), "<a src='file://{}'>Folder</a>".format(test.folder.testdir.as_posix())
            logging.exception(err)
            # raise err
    
    print("Summaries:\n\n")
    print(HTML(tabulate( [ (k,)+v for k,v in summaries.items()], [ "Test Name", "Status", "Error", "Folder" ], tablefmt ='pipe' ), whitespace="pre-wrap"))
    print()
Ejemplo n.º 21
0
 def load(self,name='details'):
     
     data = Json.load_json_from(testfolder.self[name])
     
     return data
Ejemplo n.º 22
0
def load_project_description(testfolder):
    ## temporary, later lookup test config
    project_description = Json.load_json_from(testfolder.projectdescription.resolve())    
    return project_description
Ejemplo n.º 23
0
    def setprojdir(self, testdir):

        debug(testdir)

        def showErrorMessage(errmsg, dir, ex=None):
            errorfmt = "Invalid project:<br>Dir `{1}`<br>Error `{0}`"
            if ex:
                errorfmt += "<br>Exception:<br><pre><code>{ex}</code></pre>"
            errorMessageDialog = QErrorMessage(self._parent)
            errorMessageDialog.showMessage(errorfmt.format(errmsg, dir, ex=ex))

        projectdir = Path(str(testdir))

        if not projectdir.exists():
            showErrorMessage("Project folder does not exist.", testdir)
            return

        projdescpath = projectdir / "projdesc.json"

        if not projdescpath.exists():
            showErrorMessage(" Missing projectdesc file.", str(projectdir))
            return
        else:
            try:
                projdescpath.resolve()
                self.projectdesc = Json.load_json_from(str(projdescpath))
            except Exception as err:
                logging.exception(err)
                showErrorMessage("Error loading project description: ",
                                 testdir,
                                 ex=traceback.format_exc())
                return

        try:
            self.projectdir = projectdir
            self.fs = config.FileStructure(projdescpath=projdescpath,
                                           verify=True)

            self.test_dir = self.fs.tests.resolve()
            self.testitemsd = self.fs.testitemsd()
            self.args = DataTree()

            self.args = DataTree()
            self.args.options = self.defaultoptions()

            print("Setting args: ", self.args)

            # = Emit projectdirchanged =
            print("Setting test directory:", self.test_dir)
            self.projectdirchanged.emit(str(projectdir))
            self.projectrefresh.emit()

        except Exception as err:
            traceback.print_exc(file=sys.stderr)

            # ei = boltons.tbutils.ExceptionInfo.from_current()
            # raise err

            showErrorMessage("Error setting project: ",
                             testdir,
                             ex=traceback.format_exc())
            return
Ejemplo n.º 24
0
def load_columns_json(filepath):
    return Json.load_json_from(filepath)