示例#1
0
def mail_container(container_id, address_id, condition):
    """
    Sends a request to mail a container to a given address.

    Parameters
    ----------
    container_id : str
    address_id : str
    condition : str

    Returns
    -------
    id : str

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#instr_storage
    """
    assert condition in ["ambient", "dry_ice"]
    url = "{}/containers/{}/mail".format(
        settings.get_organization(),
        container_id,
    )
    content = {
        "address": address_id,
        "condition": condition,
    }
    response = submit.post_request(
        url,
        content,
    )
    return response["id"]
示例#2
0
def get_run_data(run_id):
    """
    Get data generated by a given run.

    Parameters
    ----------
    run_id : str

    Returns
    -------
    :class:`pyscriptic.data.DataProperties`

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#data_querying
    """
    url = "{}/{}/runs/{}/data".format(
        settings.get_organization(),
        settings.get_project(),
        run_id,
    )
    response = submit.get_request(
        url,
    )
    return DataProperties(
        data_id=response["id"],
        device_class=response["device_class"],
        device_id=response["device_id"],
        dimensionality=response["dimensionality"],
        size=response["size"],
        data=response["data"],
    )
示例#3
0
def get_run(run_id):
    """
    Gets information about a single run within the currently active project.

    Parameters
    ----------
    run_id : str

    Returns
    -------
    :class:`pyscriptic.runs.RunProperties`
    """
    from pyscriptic.protocols import Protocol
    url = "{}/{}/runs/{}".format(
        settings.get_organization(),
        settings.get_project(),
        run_id,
    )
    response = submit.get_request(
        url,
    )
    return RunProperties(
        run_id=response["id"],
        title=response["title"],
        created_at=response["created_at"],
        status=response["status"],
        protocol=Protocol(
            refs=response["protocol"]["refs"],
            instructions=response["protocol"]["instructions"],
        ),
    )
示例#4
0
def get_container(container_id):
    """
    Retrieves information about a given container available within the
    currently active organization.

    Parameters
    ----------
    container_id : str

    Returns
    -------
    :class:`pyscriptic.containers.ContainerProperties`

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#containers_show
    """
    url = "{}/containers/{}".format(
        settings.get_organization(),
        container_id,
    )
    response = submit.get_request(
        url,
    )
    return _container_properties_from_response(response)
示例#5
0
def get_project(project_id):
    """
    Lists all information about a given project.

    Parameters
    ----------
    project_id : str

    Returns
    -------
    :class:`pyscriptic.project.ProjectProperties`

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#projects_get
    """
    url = "{}/{}".format(
        settings.get_organization(),
        project_id,
    )
    response = submit.get_request(
        url,
    )
    return ProjectProperties(
        project_id=response["project_id"],
        title=response["title"],
        organization=response["organization"]["id"],
        runs=response["runs"],
    )
示例#6
0
def create_project(project_id):
    """
    Creates a new project within the currently active organization.

    Parameters
    ----------
    project_id : str

    Returns
    -------
    :class:`pyscriptic.project.ProjectProperties`

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#projects_creating
    """
    url = "{}".format(
        settings.get_organization(),
    )
    content = {
        "name": project_id,
    }
    response = submit.post_request(
        url,
        content,
    )
    return ProjectProperties(
        project_id=response["project_id"],
        title=response["title"],
        organization=response["organization"]["id"],
    )
示例#7
0
def get_run(run_id):
    """
    Gets information about a single run within the currently active project.

    Parameters
    ----------
    run_id : str

    Returns
    -------
    :class:`pyscriptic.runs.RunProperties`
    """
    from pyscriptic.protocols import Protocol
    url = "{}/{}/runs/{}".format(
        settings.get_organization(),
        settings.get_project(),
        run_id,
    )
    response = submit.get_request(url, )
    return RunProperties(
        run_id=response["id"],
        title=response["title"],
        created_at=response["created_at"],
        status=response["status"],
        protocol=Protocol(
            refs=response["protocol"]["refs"],
            instructions=response["protocol"]["instructions"],
        ),
    )
示例#8
0
def get_run_data(run_id):
    """
    Get data generated by a given run.

    Parameters
    ----------
    run_id : str

    Returns
    -------
    :class:`pyscriptic.data.DataProperties`

    Notes
    -----
    .. [1] https://www.transcriptic.com/platform/#data_querying
    """
    url = "{}/{}/runs/{}/data".format(
        settings.get_organization(),
        settings.get_project(),
        run_id,
    )
    response = submit.get_request(url, )
    return DataProperties(
        data_id=response["id"],
        device_class=response["device_class"],
        device_id=response["device_id"],
        dimensionality=response["dimensionality"],
        size=response["size"],
        data=response["data"],
    )
示例#9
0
def run(request, title="PyTranscript Run", dry_run=False):
    """
    Submits a run request for the currently active project. The request should
    be in the form of a json description of the low or high-level protocol.

    Parameters
    ----------
    request : dict
    title : str, optional
    dry_run : bool, optional

    Returns
    -------
    :class:`pyscriptic.runs.RunProperties`
    """

    url = "{}/{}/runs".format(
        settings.get_organization(),
        settings.get_project(),
    )
    content = {
        "title": title,
        "request": request,
    }
    if dry_run:
        print("Posting to \"{}/{}\":".format(settings.get_base_url(), url))
        print(json.dumps(submit.pyobj_to_std_types(content), indent=2))
    else:
        response = submit.post_request(
            url,
            content,
        )
        return RunProperties(
            run_id=response["id"],
            title=response["title"],
            status=response["status"],
            warnings=response["warnings"],
            errors=response["errors"],
        )
示例#10
0
def run(request, title="PyTranscript Run", dry_run=False):
    """
    Submits a run request for the currently active project. The request should
    be in the form of a json description of the low or high-level protocol.

    Parameters
    ----------
    request : dict
    title : str, optional
    dry_run : bool, optional

    Returns
    -------
    :class:`pyscriptic.runs.RunProperties`
    """

    url = "{}/{}/runs".format(
        settings.get_organization(),
        settings.get_project(),
    )
    content = {
        "title": title,
        "request": request,
    }
    if dry_run:
        print("Posting to \"{}/{}\":".format(settings.get_base_url(), url))
        print(json.dumps(submit.pyobj_to_std_types(content), indent=2))
    else:
        response = submit.post_request(
            url,
            content,
        )
        return RunProperties(
            run_id=response["id"],
            title=response["title"],
            status=response["status"],
            warnings=response["warnings"],
            errors=response["errors"],
        )
示例#11
0
 def test_organization(self):
     settings.ORGANIZATION = "org"
     self.assertEqual(
         settings.get_organization(),
         "org",
     )
示例#12
0
 def test_organization(self):
     settings.ORGANIZATION = "org"
     self.assertEqual(
         settings.get_organization(),
         "org",
     )