Skip to content

CLI | cli interface

ewolio edited this page Feb 10, 2020 · 26 revisions

Most functionalities of the CLI are accessible through the cli object and the modules it contains:

Each of this module is an EntityTable.


Users

The cli.users interface (singleton of UserTable) allows to list, create, modify and delete users from the table user of the database.

UserTable Methods

  • cli.users.create(firstname, lastname, email, password, is_admin=False)

    Add a user to the database. This operation needs administrator privilege.

    Parameters:
    • firstname [str]: User's first name.
    • lastname [str]: User's last name.
    • email [str]: User's email. It's also the ID used by the user to authenticate to the server.
    • password [str]: User's password. As of now, the CLI doesn't encrypt the password.
    • is_admin [bool]: Set the role of the user (deprecated since more role have been added).
    Return:

    The created user as an User object.

  • cli.users.save(entity)

    Update a user of the database. Alternatively, you may call user.save(). This operation needs administrator privilege.

    Parameters:
    • entity [User]: The modified User object to save in the database.
  • cli.users.delete(entities)

    Remove a user from the database. This operation need administrator privilege.

    Parameters:
    • entities [int|User]: The id or the User object describing the user to be deleted.
    Return:

    The deleted user as an User object.

  • cli.users.list()

    List all users contained in the table user of the database.

    Return:

    The user list as an EntityList(User) object.

The User entity

A User object represents a single entity from the user table of the database.

Attributes:

  • id [int]: The index (and primary key) of the user.
  • email [str]: The user's email. It's also the id used to authenticate the user.
  • firstName [str]: The user's first name.
  • lastName [str]: The user's last name.
  • isAdmin [bool]: The user's role. (Deprecated since more role have been added.)
  • Inherited attributes from Entity

Methods:


Images

The cli.images interface (singleton of ImageTable) allows to list, upload, modify, download and delete images from the table image of the database.

ImageTable Methods

  • cli.images.create(path, type, metadata=None, preprocessing=None)

    Upload an image (and optionally its preprocessing) and add an image entry to the database. This operation needs administrator privilege. This operation may take some time since after the image uploaded, it will be converted to jpeg if needed and a thumbnail will be computed.

    Parameters:
    • path [str]: Path to the image file to upload.
    • type [str]: The acquisition type (fundus, OCT...).
    • metadata [dict]: Optional metadata passed along the images. The original name of the image and its preprocessing are automatically stored in metadata['filename'] and metadata['preprocessingFilename'].
    • preprocessing [str]: Path to the preprocessed image to upload. If None, no preprocessing is associated with this image.
    Return:

    The created user as an Image object.

  • cli.images.save(entity)

    Update an image of the database. Alternatively, you may call image.save(). Uploading a new image or preprocessing is not yet implemented in the CLI. This operation needs administrator privilege.

    Parameters:
    • entity [Image]: The modified Image object to save in the database.
  • cli.images.delete(entities)

    Remove an image from the database. This operation need administrator privilege.

    Parameters:
    • entities [int|Image]: The id or the Image object describing the image to be deleted.
    Return:

    The deleted image as an Image object.

  • cli.images.list()

    List all images contained in the table image of the database.

    Return:

    The image list as an EntityList(Image) object.

The Image entity

An Image object represents a single entity from the image table of the database.

Attributes:

  • id [int]: The index (and primary key) of the image.
  • preprocessing [bool]: True if a preprocessing image is associated with this entity.
  • metadata [dict]: The image metadata.
  • type [str]: The image acquisition type.
  • Inherited attributes from Entity

Methods:

  • image.download_image(out=None):

    Download the image file.

    Parameters:
    • out [str]: Path where the file will be written. (If none is passed the file is not stored on the disk).
    Return:

    The image as an array numpy. (Dimensions are [height, width, channel], channels are in BGR order).

  • image.download_preprocessing(out=None):

    Download the preprocessed image file.

    Parameters:
    • out [str]: Path where the file will be written. (If none is passed the file is not stored on the disk).
    Return:

    The preprocessed image as an array numpy. (Dimensions are [height, width, channel], channels are in BGR order).


Annotations

The cli.annotations interface (singleton of AnnotationTable) allows to add, list, modify, download and delete annotations from the table annotation of the database.

AnnotationTable Methods

  • cli.annotations.create(image, comment=None, data=None)

    Create an annotation.

    Parameters:
    • image [int|Image]: Id of the image or Image entity to which the annotation is linked.
    • comment [str]: Comment stored along with the annotation.
    • data [AnnotationData]: Annotation data. (see AnnotationData)
    Return:

    The created annotation as an Annotation object.

  • cli.annotations.save(entity)

    Update an image of the database. Alternatively, you may call image.save(). Uploading a new image or preprocessing is not yet implemented in the CLI. This operation needs administrator privilege.

    Parameters:
    • entity [Annotation]: The modified Annotation object to save in the database.
  • cli.annotations.list()

    List all images contained in the annotation table of the database.

    Return:

    The annotation list as an EntityList(Annotation) object.

The Annotation entity

An Annotation object represents a single entity from the annotation table of the database.

Attributes:

  • id [int]: The index (and primary key) of the annotation.
  • comment [str]: Comment associated with the annotation. This comment is not visible from the frontend, it should be used as note created by and for the research team.
  • image [Image]: The image to which this annotation is linked. Read-only
  • submitEvent [SubmissionEvent]: The last submission event. Read-only
  • Inherited attributes from Entity

Methods:

AnnotationData class

Attributes

Methods


Tasks


Tasks Types


Submission Events

Clone this wiki locally