def delete_experiment(host, port, user, password, experiment_name):
    """
    Return list of names of experiments that exist on the given TM server.
    """
    # NOTE: the experiment name is only given at initialization time...
    client = TmClient(host, port, user, password, experiment_name)
    return client.delete_experiment()
def list_experiment_names(host, port, user, password):
    """
    Return list of names of experiments that exist on the given TM server.
    """
    # it's not possible to use the generic client as a client for a
    # specific experiment, as the experiment name is only given at
    # initialization time...
    client = TmClient(host, port, user, password)
    return [exp['name'] for exp in client.get_experiments()]
Example #3
0
def run_workflow(case, host, port, user, password, experiment_name,
                 server_log=None, interval=30):
    # we really need an API client here, as the command-line
    # version does not print enough information to deduce the
    # workflow progress and termination status
    wkf_client = TmClient(host, port, user, password, experiment_name)
    if server_log:
        with open(server_log) as logfile:
            logfile.seek(0, os.SEEK_END)
            server_log_start = logfile.tell()
    try:
        wkf_client.submit_workflow()
        response = wkf_client.get_workflow_status(depth=1)
        while not response['done']:
            sleep(interval)
            # as of 2018-04-27, TM generates a 6 levels deep (!!)
            # hierarchy of tasks for the ingestion workflow -- be sure
            # we capture all of it (for better reporting and for
            # debugging purposes).
            response = wkf_client.get_workflow_status(depth=8)
            logging.debug(
                "client.get_workflow_status(%s) => %r",
                experiment_name, response)
            percent_done = compute_workflow_progress(response)
            logging.info(
                "%s: Workflow %.2f%% done.",
                experiment_name, percent_done)
        if response['failed']:
            case.fail('Workflow failed (%.2f%% done)' % percent_done)
        else:
            case.success("Workflow successfully completed!")
    except Exception as err:
        case.error(str(err))
    finally:
        # abuse test stderr to report server-side logs
        if server_log:
            with open(server_log) as logfile:
                logfile.seek(0, os.SEEK_END)
                server_log_end = logfile.tell()
                logfile.seek(server_log_start, os.SEEK_SET)
                case.stderr = logfile.read(server_log_end - server_log_start)
Example #4
0
def client(root_dir, experiment_info):
    host = 'localhost'
    port = 8002
    username = '******'
    password = '******'

    _docker_up(root_dir)
    try:
        client = TmClient(host, port, username, password, experiment_info.name)
        yield client
    except requests.ConnectionError:
        _docker_down(root_dir)
        raise OSError(
            'Client could not connect to host "{0}" on port {1}.'.format(
                host, port))
    _docker_down(root_dir)
Example #5
0
import shutil
import yaml

# Variables to be set before using the script
folderPath="/PATH/TO/TARGET/FOLDER"  # Where all the data for the test case will be saved
host="app.tissuemaps.org"
port = "80"
experimentName="NameOfExperiment"
username="******"
password="******"
folderContainingOriginalImages = ["/PATH/TO/FOLDER/CONTAINING/ORIGINAL/IMAGES"]  # List of all acquisitions
estimatedRuntime = 7200  # In seconds. After that amount, the test will run into a timeout


# Create tmclient instance
client = TmClient(host, port, username, password, experimentName)
# print json.dumps(mapobject_download,sort_keys=True, indent = 4, separators=(',', ': '))

# Write experiment_description file
exp_description = dict(
    microscope_type = "cellvoyager",
    workflow_type = "canonical",
    plate_format = 384,
    plate_acquisition_mode = "basic"
)

with open(os.path.join(folderPath,'experiment_description.yaml'),'w') as outfile:
    yaml.dump(exp_description, outfile, default_flow_style=False, explicit_start=True)

# Get plate name
plateDownload = client.get_plates()
Example #6
0
from tmclient.api import TmClient
import shutil
import yaml

# Variables to be set before using the script
folderPath = "/PATH/TO/TARGET/FOLDER"  # Where all the data for the test case will be saved
host = "app.tissuemaps.org"
port = "80"
experimentName = "NameOfExperiment"
username = "******"
password = "******"
folderContainingOriginalImages = "/PATH/TO/FOLDER/CONTAINING/ORIGINAL/IMAGES"
estimatedRuntime = 7200  # In seconds. After that amount, the test will run into a timeout

# Create tmclient instance
client = TmClient(host, port, username, password, experimentName)
# print json.dumps(mapobject_download,sort_keys=True, indent = 4, separators=(',', ': '))

# Write experiment_description file
exp_description = dict(microscope_type="cellvoyager",
                       workflow_type="canonical",
                       plate_format=384,
                       plate_acquisition_mode="basic")

with open(os.path.join(folderPath, 'experiment_description.yaml'),
          'w') as outfile:
    yaml.dump(exp_description,
              outfile,
              default_flow_style=False,
              explicit_start=True)
 def __init__(self, host, port, user, password, experiment_name):
     self._client = TmClient(host, port, user, password, experiment_name)
    if client_opt == 'api':
        return ApiTmClient(host, port, user, password, experiment_name)
    elif client_opt == 'cli':
        return CommandLineTmClient(host, port, user, password, experiment_name)
    else:
        raise RuntimeError(
            "Invalid choice for -c/--client: {}"
            .format(client_opt))


def run_workflow(case, host, port, user, password, experiment_name,
                 server_log=None, interval=30):
    # we really need an API client here, as the command-line
    # version does not print enough information to deduce the
    # workflow progress and termination status
    wkf_client = TmClient(host, port, user, password, experiment_name)
    if server_log:
        with open(server_log) as logfile:
            logfile.seek(0, os.SEEK_END)
            server_log_start = logfile.tell()
    try:
        wkf_client.submit_workflow()
        response = wkf_client.get_workflow_status(depth=1)
        while not response['done']:
            sleep(interval)
            # as of 2018-04-27, TM generates a 6 levels deep (!!)
            # hierarchy of tasks for the ingestion workflow -- be sure
            # we capture all of it (for better reporting and for
            # debugging purposes).
            response = wkf_client.get_workflow_status(depth=8)
            logging.debug(