platipy.backend package#

Subpackages#

Submodules#

platipy.backend.api module#

class platipy.backend.api.AlgorithmEndpoint#

Bases: Resource

endpoint = 'algorithmendpoint'#
get()#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class platipy.backend.api.CustomConfig#

Bases: object

RESTFUL_JSON = {'cls': <class 'platipy.backend.models.AlchemyEncoder'>, 'indent': 2, 'separators': (', ', ': ')}#
class platipy.backend.api.DataObjectDownloadEndpoint#

Bases: Resource

endpoint = 'dataobjectdownloadendpoint'#
get(dataobject_id)#

Returns the file for the given dataobject

mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
class platipy.backend.api.DataObjectEndpoint#

Bases: Resource

delete(dataobject_id)#
endpoint = 'dataobjectendpoint'#
get(dataobject_id)#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'DELETE', 'GET', 'POST'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
post()#
class platipy.backend.api.DataObjectsEndpoint#

Bases: Resource

endpoint = 'dataobjectsendpoint'#
get()#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class platipy.backend.api.DatasetEndpoint#

Bases: Resource

endpoint = 'datasetendpoint'#
get(dataset_id)#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'POST'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
post()#
class platipy.backend.api.DatasetReadyEndpoint#

Bases: Resource

endpoint = 'datasetreadyendpoint'#
get(dataset_id)#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
class platipy.backend.api.DatasetsEndpoint#

Bases: Resource

endpoint = 'datasetsendpoint'#
get()#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class platipy.backend.api.DicomLocationEndpoint#

Bases: Resource

endpoint = 'dicomlocationendpoint'#
get()#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'POST'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
post()#
class platipy.backend.api.Resource#

Bases: Resource

method_decorators = [<function authenticate>]#
class platipy.backend.api.TaskStatus#

Bases: Resource

endpoint = 'taskstatus'#
get(task_id)#

Get the status of a task given the ID

mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'GET'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class platipy.backend.api.TriggerEndpoint#

Bases: Resource

endpoint = 'triggerendpoint'#
mediatypes()#
methods: t.ClassVar[t.Collection[str] | None] = {'POST'}#

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

parser = <flask_restful.reqparse.RequestParser object>#
post()#
platipy.backend.api.authenticate(func)#

platipy.backend.application module#

class platipy.backend.application.Algorithm(name, function, default_settings)#

Bases: object

settings_to_json()#
class platipy.backend.application.FlaskApp(import_name: str, static_url_path: Optional[str] = None, static_folder: str | os.PathLike | None = 'static', static_host: Optional[str] = None, host_matching: bool = False, subdomain_matching: bool = False, template_folder: str | os.PathLike | None = 'templates', instance_path: Optional[str] = None, instance_relative_config: bool = False, root_path: Optional[str] = None)#

Bases: Flask

Custom Flask App

algorithms = {}#
api = None#
beat_started = False#
celery_started = False#
dicom_listener_aetitle = 'PLATIPY_SERVICE'#
dicom_listener_port = 7777#
register(name, default_settings=None)#
run(host=None, port=None, debug=None, dicom_listener_port=7777, dicom_listener_aetitle='PLATIPY_SERVICE', load_dotenv=True, **options)#

Runs the application on a local development server.

Do not use run() in a production setting. It is not intended to meet security and performance requirements for a production server. Instead, see /deploying/index for WSGI server recommendations.

If the debug flag is set the server will automatically reload for code changes and show a debugger in case an exception happened.

If you want to run the application in debug mode, but disable the code execution on the interactive debugger, you can pass use_evalex=False as parameter. This will keep the debugger’s traceback screen active, but disable code execution.

It is not recommended to use this function for development with automatic reloading as this is badly supported. Instead you should be using the flask command line script’s run support.

Keep in Mind

Flask will suppress any server error with a generic error page unless it is in debug mode. As such to enable just the interactive debugger without the code reloading, you have to invoke run() with debug=True and use_reloader=False. Setting use_debugger to True without being in debug mode won’t catch any exceptions because there won’t be any to catch.

Parameters:
  • host – the hostname to listen on. Set this to '0.0.0.0' to have the server available externally as well. Defaults to '127.0.0.1' or the host in the SERVER_NAME config variable if present.

  • port – the port of the webserver. Defaults to 5000 or the port defined in the SERVER_NAME config variable if present.

  • debug – if given, enable or disable debug mode. See debug.

  • load_dotenv – Load the nearest .env and .flaskenv files to set environment variables. Will also change the working directory to the directory containing the first file found.

  • options – the options to be forwarded to the underlying Werkzeug server. See werkzeug.serving.run_simple() for more information.

Changed in version 1.0: If installed, python-dotenv will be used to load environment variables from .env and .flaskenv files.

The FLASK_DEBUG environment variable will override debug.

Threaded mode is enabled by default.

Changed in version 0.10: The default port is now picked from the SERVER_NAME variable.

run_dicom_listener(listen_port=None, listen_ae_title=None)#

Background task that listens at a specific port for incoming dicom series

platipy.backend.client module#

platipy.backend.manage module#

platipy.backend.manage.add_api_key(name, is_admin)#

Add a new API Key with the given name

name: Name of the API Key

platipy.backend.manage.create_db()#

Create the Database used by the framework

platipy.backend.manage.run_celery()#

platipy.backend.models module#

class platipy.backend.models.APIKey(**kwargs)#

Bases: Model

is_admin#
key#
name#
class platipy.backend.models.AlchemyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#

Bases: JSONEncoder

default(obj)#

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class platipy.backend.models.DataObject(**kwargs)#

Bases: Model

children#
dataset#
dataset_id#
id#
is_fetched#
is_input#
is_sent#
meta_data#
parent#
parent_id#
path#
series_instance_uid#
status#
timestamp#
type#
class platipy.backend.models.Dataset(**kwargs)#

Bases: Model

from_dicom_location#
from_dicom_location_id#
id#
input_data_objects#
output_data_objects#
owner_key#
timeout#
timestamp#
to_dicom_location#
to_dicom_location_id#
class platipy.backend.models.DicomLocation(**kwargs)#

Bases: Model

ae_title#
host#
id#
name#
owner_key#
port#
platipy.backend.models.default_timeout()#

platipy.backend.tasks module#

platipy.backend.views module#

platipy.backend.views.add_endpoint()#
platipy.backend.views.dashboard()#

Entry point to the dashboard of the application

platipy.backend.views.fetch_log()#
platipy.backend.views.fetch_status()#
platipy.backend.views.view_endpoint(id)#

Module contents#

platipy.backend.configure_logging()#
platipy.backend.on_celery_setup_logging(**kwargs)#