def testExportSteps(self):

        manager = Manager()
        stepsStats = dict()

        for project in manager.listProjects():
            projectFolder = manager.getProjectPath(project.projName)

            project = Project(pyworkflow.Config.getDomain(), projectFolder)
            project.load()

            for prot in project.getRuns():
                protName = prot.getClassName()
                for step in prot.loadSteps():
                    stepName = "-".join([
                        prot.getClassPackageName(), protName,
                        step.funcName.get()
                    ])
                    stepSeconds = step.getElapsedTime().total_seconds()
                    if stepName not in stepsStats:
                        stepsStats[stepName] = []

                    stepsStats[stepName].append(stepSeconds)

        # average steps
        for name in stepsStats:
            plugin, protClass, step = name.split("-")
            stepStats = stepsStats[name]
            mean = sum(stepStats) / len(stepStats)
            # DO not send mean values if higher than a threshold to keep chart in a decent visualization range
            # We are loosing long duration steps, probably due to large
            if mean < 30:
                bm = Benchmark(time=mean, name="-".join([protClass, step]))
                codespeed.sendData(bm)
manager = Manager()

if not manager.hasProject(projName):
    usage("There is no project with this name: %s"
          % pwutils.red(projName))

# the project may be a soft link which may be unavailable to the cluster so get the real path
try:
    projectPath = os.readlink(manager.getProjectPath(projName))
except:
    projectPath = manager.getProjectPath(projName)

project = Project(pw.Config.getDomain(), projectPath)
project.load()

runs = project.getRuns()

# Now assuming that there is no dependencies between runs
# and the graph is lineal
for prot in runs:
    protClassName = prot.getClassName()
    protLabelName = prot.getObjLabel()
    if (protClassName not in sys.argv[3:] and
            protLabelName not in sys.argv[3:]):
        project.scheduleProtocol(prot)
        # Wait 1 seconds to avoid concurrent activity
        time.sleep(0.7)
    else:
        print(pwutils.blueStr("\nNot scheduling '%s' protocol named '%s'.\n"
                              % (protClassName, protLabelName)))
Beispiel #3
0
if n <>2:
    usage("This script accepts 1 parameter: the project name.")

projName = sys.argv[1]

path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'gui', 'no-tkinter')
sys.path.insert(1, path)

# Create a new project
manager = Manager()

if not manager.hasProject(projName):
    usage("There is no project with this name: %s"
          % pwutils.red(projName))

# the project may be a soft link which may be unavailable to the cluster so get the real path
try:
    projectPath = os.readlink(manager.getProjectPath(projName))
except:
    projectPath = manager.getProjectPath(projName)

project = Project(projectPath)
project.load()

runs = project.getRuns()

# Now assuming that there is no dependencies between runs
# and the graph is lineal
for prot in runs:
    project.scheduleProtocol(prot)