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 are an EntityTable.


Users

The cli.users interface allow 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.update(user)

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

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

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

    Parameters:
    • user [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.)

Images

The cli.images interface allow 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 optionnaly 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 metadat['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.update(image)

    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:
    • image [Image]: The modified Image object to save in the database.
  • cli.images.delete(image)

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

    Parameters:
    • image [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.

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

Tasks

Tasks Types

Submission Events

Clone this wiki locally