Code Reference

studygovernor Package

studygovernor.create_app(test_config=None, use_sentry=True)
studygovernor.load_app_config(app, test_config)
studygovernor.set_config_defaults(config)
studygovernor.set_default_config_value(config, key, value, warning=None)

studygovernor.exceptions Module

exception studygovernor.exceptions.ConditionFunctionCallFailedError(condition, function, args, kwargs, stacktrace)

Bases: studygovernor.exceptions.StateChangeError

exception studygovernor.exceptions.ConditionFunctionReturnValueError(condition, function, args, kwargs, return_value)

Bases: studygovernor.exceptions.ConditionFunctionCallFailedError

exception studygovernor.exceptions.ConditionNotMetError(experiment, transition, condition)

Bases: studygovernor.exceptions.StateChangeError

exception studygovernor.exceptions.CouldNotFindResourceError(id_, type_, message=None)

Bases: studygovernor.exceptions.StudyGovernorHTTPError

Could not find a resource

code = 404
exception studygovernor.exceptions.NoValidTransitionError(sourcestate, targetstate)

Bases: studygovernor.exceptions.StateChangeError

exception studygovernor.exceptions.RESTResponseError

Bases: studygovernor.exceptions.StudyGovernorClientError

The REST response is not what was expected

exception studygovernor.exceptions.StateChangeError

Bases: studygovernor.exceptions.StudyGovernorError

Exceptions encountered during a state change

exception studygovernor.exceptions.StateNotFoundError(requested_state)

Bases: studygovernor.exceptions.StateChangeError

exception studygovernor.exceptions.StudyGovernorClientError

Bases: studygovernor.exceptions.StudyGovernorError

Error class for all client-side errors

exception studygovernor.exceptions.StudyGovernorError

Bases: Exception

Base class for exceptions in the study governor codebase

property fields
marshal(api_prefix)
exception studygovernor.exceptions.StudyGovernorHTTPError(description, response=None)

Bases: studygovernor.exceptions.StudyGovernorError, werkzeug.exceptions.HTTPException

All exceptions that should lead to an HTTP error response

code = 500
property description
exception studygovernor.exceptions.StudyGovernorSSLError

Bases: studygovernor.exceptions.StudyGovernorClientError

There was a problem creating an SSL connection

exception studygovernor.exceptions.UnknownConditionFunction(condition, module, function)

Bases: studygovernor.exceptions.StateChangeError

studygovernor.fields Module

class studygovernor.fields.MappingField(**kwargs)

Bases: flask_restplus.fields.Raw

format(value)

Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.

Parameters

value – The value to format

Raises

MarshallingError – In case of formatting problem

Ex:

class TitleCase(Raw):
    def format(self, value):
        return unicode(value).title()
class studygovernor.fields.ObjectUrl(object_class, api_prefix=None, **kwargs)

Bases: flask_restplus.fields.Raw

format(value)

Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.

Parameters

value – The value to format

Raises

MarshallingError – In case of formatting problem

Ex:

class TitleCase(Raw):
    def format(self, value):
        return unicode(value).title()
class studygovernor.fields.SubUrl(object_class, subfield, **kwargs)

Bases: flask_restplus.fields.Raw

format(value)

Formats a field’s value. No-op by default - field classes that modify how the value of existing object keys should be presented should override this and apply the appropriate formatting.

Parameters

value – The value to format

Raises

MarshallingError – In case of formatting problem

Ex:

class TitleCase(Raw):
    def format(self, value):
        return unicode(value).title()

studygovernor.util.filters Module

studygovernor.util.filters.hyphenate_filter(s)

Filter for lowercasing and hyphenating a string.

studygovernor.util.filters.json_format_filter(s)

Filter for pretty formatting json’s.

studygovernor.util.filters.register_filters(app)

Special function that registers all member of this module ending in “_filter”.

studygovernor.util.helpers Module

studygovernor.util.helpers.get_object_from_arg(id, model, model_name=None, skip_id=False, allow_none=False)
studygovernor.util.helpers.initialize_workflow(workflow, app, verbose=False, force=True)
studygovernor.util.helpers.load_config_file(app, file_path, silent=False)

studygovernor.models Module

class studygovernor.models.Action(experiment=None, transition=None, freetext=None)

Bases: sqlalchemy.ext.declarative.api.Model

end_time
experiment_id
freetext
id
return_value
start_time
success
transition_id
class studygovernor.models.Condition(rule=None, freetext=None)

Bases: sqlalchemy.ext.declarative.api.Model

check(experiment)
freetext
id
rule
transitions
class studygovernor.models.Experiment(subject=None, label=None, scandate=None)

Bases: sqlalchemy.ext.declarative.api.Model

actions
property external_ids
find_external_id(external_system_name)
id
init_state()
label
scandate
scans
set_state(target_state, api_prefix='api_v1', freetext=None)
property state
subject
subject_id

Bases: sqlalchemy.ext.declarative.api.Model

experiment
experiment_id
external_id
external_system
external_system_id
id

Bases: sqlalchemy.ext.declarative.api.Model

external_id
external_system
external_system_id
id
subject
subject_id
class studygovernor.models.ExternalSystem(id=None, system_name=None, url=None)

Bases: sqlalchemy.ext.declarative.api.Model

id
system_name
url
class studygovernor.models.Role(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Model, studygovernor.auth.models.BaseRole

This implements the BaseRole from the .auth.models module. In this specific case, the BaseRole is sufficient.

description
id
name
permissions
update_datetime
users
class studygovernor.models.Scan(experiment=None, scantype=None)

Bases: sqlalchemy.ext.declarative.api.Model

experiment
experiment_id
id
scantype
scantype_id
class studygovernor.models.Scantype(id=None, modality=None, protocol=None)

Bases: sqlalchemy.ext.declarative.api.Model

id
modality
protocol
scans
class studygovernor.models.State(id=None, label=None, callback=None, lifespan=None, freetext=None)

Bases: sqlalchemy.ext.declarative.api.Model

callback
property experiments
freetext
get_transition_to(target_state)
id
label
lifespan
property lifespan_timedelta
transition_destinations
transition_sources
class studygovernor.models.Subject(label=None, date_of_birth=None)

Bases: sqlalchemy.ext.declarative.api.Model

date_of_birth
experiments
property external_ids
id
label
class studygovernor.models.Transition(id=None, source_state=None, destination_state=None, conditions=None)

Bases: sqlalchemy.ext.declarative.api.Model

actions
conditions
destination_state
destination_state_id
id
source_state
source_state_id
class studygovernor.models.User(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Model, studygovernor.auth.models.BaseUser

active
confirmed_at
create_datetime
create_time
current_login_at
current_login_ip
email
fs_uniquifier
id
last_login_at
last_login_ip
login_count
name
password
roles
tf_phone_number
tf_primary_method
tf_totp_secret
update_datetime
username

studygovernor.views Module

studygovernor.views.forbidden_error(error)
studygovernor.views.index()
studygovernor.views.page_not_found_error(error)
studygovernor.views.user(id)
studygovernor.views.users()
studygovernor.views.web_action(id)
studygovernor.views.web_experiment(id)
studygovernor.views.web_experiments()
studygovernor.views.web_state(id)
studygovernor.views.web_states()
studygovernor.views.web_subject(id)
studygovernor.views.web_subjects()
studygovernor.views.web_transition(id)
studygovernor.views.web_transitions()