コード例 #1
0
def omero_url_reader(path):
    match = parse_omero_url(path)
    gateway = get_gateway(path, match.get("host"))
    if match.get("type").lower() == ("image"):
        wrapper = _lookup(gateway,
                          ProxyStringType("Image")(f"Image:{match.get('id')}"))
        if wrapper:
            return load_omero_wrapper(wrapper)
コード例 #2
0
    def _configure(self, parser):

        parser.add_login_arguments()
        sub = parser.sub()

        images = parser.add(sub, self.images)
        images.add_style_argument()
        images.add_limit_arguments()
        images.add_argument("--order",
                            default="newest",
                            choices=("newest", "oldest", "largest"),
                            help="order of the rows returned")
        images.add_argument("--archived",
                            action="store_true",
                            help="list only images with archived data")

        rename = parser.add(sub, self.rename)
        rename.add_argument(
            "fileset",
            type=ProxyStringType("Fileset"),
            help="Fileset which should be renamed: ID or Fileset:ID")
        rename.add_argument("--no-move",
                            action="store_true",
                            help="do not move original files and import log")

        repos = parser.add(sub, self.repos)
        repos.add_style_argument()
        repos.add_argument("--managed",
                           action="store_true",
                           help="repos only managed repositories")

        sets = parser.add(sub, self.sets)
        sets.add_style_argument()
        sets.add_limit_arguments()
        sets.add_argument("--order",
                          default="newest",
                          choices=("newest", "oldest", "prefix"),
                          help="order of the rows returned")
        sets.add_argument("--without-images",
                          action="store_true",
                          help="list only sets without images (i.e. corrupt)")
        sets.add_argument("--with-transfer",
                          nargs="+",
                          action="append",
                          help="list sets by their in-place import method")
        sets.add_argument(
            "--check",
            action="store_true",
            help="checks each fileset for validity (admins only)")

        for x in (images, sets):
            x.add_argument("--extended",
                           action="store_true",
                           help="provide more details for each (slow)")
コード例 #3
0
def omero_url_reader(path: str) -> List[LayerData]:
    match = parse_omero_url(path)
    if not match:
        return []
    gateway = get_gateway(path, match.get("host"))
    if match.get("type", "").lower() == "image":
        wrapper = lookup_obj(
            gateway,
            ProxyStringType("Image")(f"Image:{match.get('id')}"))
        if isinstance(wrapper, ImageWrapper):
            return load_image_wrapper(wrapper)
    return []
コード例 #4
0
ファイル: download.py プロジェクト: ome/omero-py
 def _configure(self, parser):
     parser.add_argument("object",
                         type=ProxyStringType("OriginalFile"),
                         help="Object to download of form <object>:<id>. "
                         "OriginalFile is assumed if <object>: is omitted.")
     parser.add_argument(
         "filename",
         help=
         "Local filename (or path for Fileset) to be saved to. '-' for stdout"
     )
     parser.set_defaults(func=self.__call__)
     parser.add_login_arguments()
コード例 #5
0
    def _configure(self, parser):
        parser.add_login_arguments()
        sub = parser.sub()
        info = parser.add(sub, self.info, DESC["INFO"])
        copy = parser.add(sub, self.copy, DESC["COPY"])
        edit = parser.add(sub, self.edit, DESC["EDIT"])
        test = parser.add(sub, self.test, DESC["TEST"])
        # list = parser.add(sub, self.list, DESC["LIST"])
        # jpeg = parser.add(sub, self.jpeg, DESC["JPEG"])
        # jpeg.add_argument(
        #    "--out", default="-",
        #    help="Local filename to be saved to. '-' for stdout")

        render_type = ProxyStringType("Image")
        render_help = ("rendering def source of form <object>:<id>. "
                       "Image is assumed if <object>: is omitted.")

        for x in (info, copy, edit, test):
            x.add_argument("object", type=render_type, help=render_help)

        edit.add_argument(
            "--copy",
            help="Batch edit images by copying rendering settings",
            action="store_true")

        for x in (copy, edit):
            x.add_argument("--skipthumbs",
                           help="Don't re-generate thumbnails",
                           action="store_true")

        output_formats = ['plain'] + list(
            pydict_text_io.get_supported_formats())
        info.add_argument("--style",
                          choices=output_formats,
                          default='plain',
                          help="Output format")

        copy.add_argument("target",
                          type=render_type,
                          help=render_help,
                          nargs="+")
        edit.add_argument(
            "channels",
            help="Rendering definition, local file or OriginalFile:ID")

        test.add_argument("--force", action="store_true")
        test.add_argument("--thumb", action="store_true")
コード例 #6
0
def run(studyfile, targetstr):
    try:
        # `omero shell --login` automatically creates the client object
        session = client.getSession()
        cli = None
    except NameError:
        cli = CLI()
        cli.loadplugins()
        cli.onecmd('login')
        session = cli.get_client().getSession()

    try:
        us = session.getUpdateService()

        target = ProxyStringType()(targetstr)
        with open(studyfile) as f:
            rowkvs = get_pairs(f)
        links = create_map_annotation([target], rowkvs, ns)
        ids = us.saveAndReturnIds(links)
        print 'Created MapAnnotation links: %s' % ids
    finally:
        if cli:
            cli.close()
コード例 #7
0
ファイル: fs.py プロジェクト: patrick330602/fomf3dbd
    def _configure(self, parser):

        parser.add_login_arguments()
        sub = parser.sub()

        images = parser.add(sub, self.images)
        images.add_style_argument()
        images.add_limit_arguments()
        images.add_argument(
            "--order", default="newest",
            choices=("newest", "oldest", "largest"),
            help="order of the rows returned")
        images.add_argument(
            "--archived", action="store_true",
            help="list only images with archived data")

        mkdir = parser.add(sub, self.mkdir)
        mkdir.add_argument(
            "new_dir",
            help="directory to create in the repository")
        mkdir.add_argument(
            "--parents", action="store_true",
            help="ensure whole path exists")

        rename = parser.add(sub, self.rename)
        rename.add_argument(
            "fileset",
            type=ProxyStringType("Fileset"),
            help="Fileset which should be renamed: ID or Fileset:ID")
        rename.add_argument(
            "--no-move", action="store_true",
            help="do not move original files and import log")

        repos = parser.add(sub, self.repos)
        repos.add_style_argument()
        repos.add_argument(
            "--managed", action="store_true",
            help="repos only managed repositories")

        sets = parser.add(sub, self.sets)
        sets.add_style_argument()
        sets.add_limit_arguments()
        sets.add_argument(
            "--order", default="newest",
            choices=("newest", "oldest", "prefix"),
            help="order of the rows returned")
        sets.add_argument(
            "--without-images", action="store_true",
            help="list only sets without images (i.e. corrupt)")
        sets.add_argument(
            "--with-transfer", nargs="+", action="append",
            help="list sets by their in-place import method")
        sets.add_argument(
            "--check", action="store_true",
            help="verify the file checksums for each fileset (admins only)")

        ls = parser.add(sub, self.ls)
        ls.add_argument(
            "fileset",
            type=ProxyStringType("Fileset"))

        logfile = parser.add(sub, self.logfile)
        logfile.add_argument("fileset", type=ProxyStringType("Fileset"))
        logfile.add_argument(
            "filename",  nargs="?", default="-",
            help="Local filename to be saved to. '-' for stdout")
        logopts = logfile.add_mutually_exclusive_group()
        logopts.add_argument(
            "--name", action="store_true",
            help="return the path of the logfile within the ManagedRepository")
        logopts.add_argument(
            "--size", action="store_true",
            help="return the size of the logfile in bytes")

        usage = parser.add(sub, self.usage)
        usage.set_args_unsorted()
        usage.add_login_arguments()
        usage.add_style_argument()
        usage.add_argument(
            "--wait", type=long,
            help="Number of seconds to wait for the processing to complete "
            "(Indefinite < 0; No wait=0).", default=-1)
        usage.add_argument(
            "--size-only", action="store_true",
            help="Print total bytes used in bytes")
        usage.add_argument(
            "--report", action="store_true",
            help="Print detailed breakdown of disk usage")
        usage.add_argument(
            "--sum-by", nargs="+", choices=("user", "group", "component"),
            help=("Breakdown of disk usage by a combination of "
                  "user, group and component"))
        usage.add_argument(
            "--sort-by", nargs="+",
            choices=("user", "group", "component", "size", "files"),
            help=("Sort the report table by one or more of "
                  "user, group, component, size and files"))
        usage.add_argument(
            "--reverse", action="store_true",
            help="Reverse sort order")
        unit_group = usage.add_mutually_exclusive_group()
        unit_group.add_argument(
            "--units", choices="KMGTP",
            help="Units to use for disk usage")
        unit_group.add_argument(
            "--human-readable", action="store_true",
            help="Use most appropriate units")
        usage.add_argument(
            "--groups",  action="store_true",
            help="Print size for all current user's groups")
        usage.add_argument(
            "obj", nargs="*",
            help=("Objects to be queried in the form "
                  "'<Class>:<Id>[,<Id> ...]', or '<Class>:*' "
                  "to query all the objects of the given type "))

        for x in (images, sets):
            x.add_argument(
                "--extended", action="store_true",
                help="provide more details for each (slow)")
コード例 #8
0
ファイル: utils.py プロジェクト: will-moore/napari-omero
logger = logging.getLogger(__name__)

PIXEL_TYPES = {
    omero_enums.PixelsTypeint8: np.int8,
    omero_enums.PixelsTypeuint8: np.uint8,
    omero_enums.PixelsTypeint16: np.int16,
    omero_enums.PixelsTypeuint16: np.uint16,
    omero_enums.PixelsTypeint32: np.int32,
    omero_enums.PixelsTypeuint32: np.uint32,
    omero_enums.PixelsTypefloat: np.float32,
    omero_enums.PixelsTypedouble: np.float64,
}

PROXIES = (
    ProxyStringType("Image"),
    ProxyStringType("Dataset"),
    ProxyStringType("Project"),
)


def timer(func):
    """Print the runtime of the decorated function"""
    @functools.wraps(func)
    def wrapper_timer(*args, **kwargs):
        start_time = time.perf_counter()  # 1
        value = func(*args, **kwargs)
        end_time = time.perf_counter()  # 2
        run_time = end_time - start_time  # 3
        logger.debug(f"Finished {func.__name__!r} in {run_time:.4f} secs")
        return value
コード例 #9
0
ファイル: metadata.py プロジェクト: patrick330602/fomf3dbd
    def _configure(self, parser):
        parser.add_login_arguments()

        sub = parser.sub()
        summary = parser.add(sub, self.summary)
        original = parser.add(sub, self.original)
        measures = parser.add(sub, self.measures)
        bulkanns = parser.add(sub, self.bulkanns)
        mapanns = parser.add(sub, self.mapanns)
        allanns = parser.add(sub, self.allanns)
        parser.add(sub, self.testtables)
        rois = parser.add(sub, self.rois)
        populate = parser.add(sub, self.populate)
        populateroi = parser.add(sub, self.populateroi)
        pixelsize = parser.add(sub, self.pixelsize)

        populate.add_argument("--batch",
                              type=long,
                              default=1000,
                              help="Number of objects to process at once")
        self._add_wait(populate)

        for x in (summary, original, bulkanns, measures, mapanns, allanns,
                  rois, populate, populateroi, pixelsize):
            x.add_argument("obj",
                           type=ProxyStringType(),
                           help="Object in Class:ID format")

        for x in (bulkanns, measures, mapanns, allanns, rois, populate,
                  populateroi):
            x.add_argument("--report",
                           action="store_true",
                           help=("Show additional information"))

        for x in (rois, populate, populateroi):
            dry_or_not = x.add_mutually_exclusive_group()
            dry_or_not.add_argument("-n", "--dry-run", action="store_true")
            dry_or_not.add_argument("-f",
                                    "--force",
                                    action="store_false",
                                    dest="dry_run")

        for x in (bulkanns, measures, mapanns, allanns):
            x.add_argument("--parents",
                           action="store_true",
                           help="Also search parents for annotations")

        for x in (mapanns, allanns):
            x.add_argument("--ns",
                           default=None,
                           help="Restrict to this namespace")
            x.add_argument(
                "--nsre",
                help="Restrict to this namespace (regular expression)")

        rois.add_argument("--delete",
                          action="store_true",
                          help="Delete all ROIs")

        populate.add_argument("--context",
                              default=self.POPULATE_CONTEXTS[0][0],
                              choices=[a[0] for a in self.POPULATE_CONTEXTS])

        datafile = populate.add_mutually_exclusive_group()
        datafile.add_argument("--file", help="Input file")
        datafile.add_argument("--fileid",
                              type=long,
                              help="Input OriginalFile ID")

        cfgfile = populate.add_mutually_exclusive_group()
        cfgfile.add_argument("--cfg", help="YAML configuration file")
        cfgfile.add_argument("--cfgid",
                             type=long,
                             help="YAML configuration OriginalFile ID")

        populate.add_argument(
            "--attach",
            action="store_true",
            help=
            ("Upload input or configuration files and attach to parent object"
             ))

        populate.add_argument(
            "--localcfg",
            help=("Local configuration file or a JSON object string"))

        populateroi.add_argument(
            "--measurement",
            type=int,
            default=None,
            help="Index of the measurement to populate. By default, all")

        pixelsize.add_argument("--x",
                               type=float,
                               default=None,
                               help="Physical pixel size X")
        pixelsize.add_argument("--y",
                               type=float,
                               default=None,
                               help="Physical pixel size Y")
        pixelsize.add_argument("--z",
                               type=float,
                               default=None,
                               help="Physical pixel size Z")
        pixelsize.add_argument(
            "--unit",
            default="micrometer",
            help="Unit (nanometer, micrometer, etc.) (default: micrometer)")