Exemplo n.º 1
0
    def session_length_stats(self):
        session_lens = Action.query.join(Action, Session.actions)\
                .filter(Session.analysis_id == self.id)\
                .with_entities(Session.id,
                               func.count(Action.id).label('length'))\
                .group_by(Session.id)\
                .subquery()

        return db.session.query(
            func.avg(session_lens.c.length).label('avg'),
            func.stddev_pop(session_lens.c.length).label('std')).first()
Exemplo n.º 2
0
def get_slow_pages(path=None):
    l = label("average", func.avg(ViewLog.load_time))
    c = label("count", func.count(ViewLog.id))

    return (
        DBSession.query(
            ViewLog.path,
            l,
            c,
            label("cumulative_time", func.sum(ViewLog.load_time)),
            label("stddev", func.stddev_pop(ViewLog.load_time)),
            label("maximum", func.max(ViewLog.load_time)),
            label("minimum", func.min(ViewLog.load_time)),
        )
        .filter(ViewLog.path == path if path != None else True)
        .having(c > 2)
        .group_by(ViewLog.path)
        .order_by(l.desc())
    )
Exemplo n.º 3
0
from ceilometer.storage import models as api_models
from ceilometer.storage.sqlalchemy import models
from ceilometer.storage.sqlalchemy import utils as sql_utils
from ceilometer import utils

LOG = log.getLogger(__name__)

STANDARD_AGGREGATES = dict(avg=func.avg(models.Sample.volume).label('avg'),
                           sum=func.sum(models.Sample.volume).label('sum'),
                           min=func.min(models.Sample.volume).label('min'),
                           max=func.max(models.Sample.volume).label('max'),
                           count=func.count(
                               models.Sample.volume).label('count'))

UNPARAMETERIZED_AGGREGATES = dict(
    stddev=func.stddev_pop(models.Sample.volume).label('stddev'))

PARAMETERIZED_AGGREGATES = dict(
    validate=dict(
        cardinality=lambda p: p in ['resource_id', 'user_id', 'project_id']),
    compute=dict(cardinality=lambda p: func.count(
        distinct(getattr(models.Resource, p))).label('cardinality/%s' % p)))

AVAILABLE_CAPABILITIES = {
    'meters': {
        'query': {
            'simple': True,
            'metadata': True
        }
    },
    'resources': {
Exemplo n.º 4
0
from ceilometer.storage.sqlalchemy import utils as sql_utils
from ceilometer import utils

LOG = log.getLogger(__name__)


STANDARD_AGGREGATES = dict(
    avg=func.avg(models.Sample.volume).label('avg'),
    sum=func.sum(models.Sample.volume).label('sum'),
    min=func.min(models.Sample.volume).label('min'),
    max=func.max(models.Sample.volume).label('max'),
    count=func.count(models.Sample.volume).label('count')
)

UNPARAMETERIZED_AGGREGATES = dict(
    stddev=func.stddev_pop(models.Sample.volume).label('stddev')
)

PARAMETERIZED_AGGREGATES = dict(
    validate=dict(
        cardinality=lambda p: p in ['resource_id', 'user_id', 'project_id']
    ),
    compute=dict(
        cardinality=lambda p: func.count(
            distinct(getattr(models.Resource, p))
        ).label('cardinality/%s' % p)
    )
)

AVAILABLE_CAPABILITIES = {
    'meters': {'query': {'simple': True,
Exemplo n.º 5
0
gene_expression_data = ome.query(
          Gene.id.label('gene_id'),
          Gene.name.label('gene_name'),
          Gene.locus_id.label('locus_id'),
          Strain.id.label('strain_id'),
          Strain.name.label('strain'),
          InVivoEnvironment.id.label('environment_id'),
          InVivoEnvironment.carbon_source.label('carbon_source'),
          InVivoEnvironment.nitrogen_source.label('nitrogen_source'),
          InVivoEnvironment.electron_acceptor.label('electron_acceptor'),
          DataSet.type.label('dataset_type'),
          DataSet.group_name.label('group_name'),
          func.max(DataSet.id).label('max_dataset_id'),
          func.avg(GenomeData.value).label('value'),
          func.stddev_pop(GenomeData.value).label('stddev')).\
    join(GenomeData, DataSet, Strain, InVivoEnvironment).\
    group_by(Gene.id, DataSet.group_name, Strain.id, DataSet.type, InVivoEnvironment.id,
             Gene.locus_id, Gene.name, Strain.name, InVivoEnvironment.carbon_source,
                                                    InVivoEnvironment.nitrogen_source,
                                                    InVivoEnvironment.electron_acceptor).order_by(DataSet.type, InVivoEnvironment.id).subquery()



class GeneExpressionData(Base):
    __table__ = gene_expression_data

    __mapper_args__ = {
        'primary_key':[gene_expression_data.c.gene_id, gene_expression_data.c.max_dataset_id]
    }
Exemplo n.º 6
0
gene_expression_data = ome.query(
          Gene.id.label('gene_id'),
          Gene.name.label('gene_name'),
          Gene.locus_id.label('locus_id'),
          Strain.id.label('strain_id'),
          Strain.name.label('strain'),
          InVivoEnvironment.id.label('environment_id'),
          InVivoEnvironment.carbon_source.label('carbon_source'),
          InVivoEnvironment.nitrogen_source.label('nitrogen_source'),
          InVivoEnvironment.electron_acceptor.label('electron_acceptor'),
          Dataset.type.label('dataset_type'),
          Dataset.group_name.label('group_name'),
          func.max(Dataset.id).label('max_dataset_id'),
          func.avg(GenomeData.value).label('value'),
          func.stddev_pop(GenomeData.value).label('stddev')).\
    join(GenomeData, Dataset, Strain, InVivoEnvironment).\
    group_by(Gene.id, Dataset.group_name, Strain.id, Dataset.type, InVivoEnvironment.id,
             Gene.locus_id, Gene.name, Strain.name, InVivoEnvironment.carbon_source,
                                                    InVivoEnvironment.nitrogen_source,
                                                    InVivoEnvironment.electron_acceptor).order_by(Dataset.type, InVivoEnvironment.id).subquery()


class GeneExpressionData(Base):
    __table__ = gene_expression_data

    __mapper_args__ = {
        'primary_key': [
            gene_expression_data.c.gene_id,
            gene_expression_data.c.max_dataset_id
        ]
Exemplo n.º 7
0
from ceilometer.storage.sqlalchemy import models
from ceilometer.storage.sqlalchemy import utils as sql_utils
from ceilometer import utils

LOG = log.getLogger(__name__)


STANDARD_AGGREGATES = dict(
    avg=func.avg(models.Sample.volume).label("avg"),
    sum=func.sum(models.Sample.volume).label("sum"),
    min=func.min(models.Sample.volume).label("min"),
    max=func.max(models.Sample.volume).label("max"),
    count=func.count(models.Sample.volume).label("count"),
)

UNPARAMETERIZED_AGGREGATES = dict(stddev=func.stddev_pop(models.Sample.volume).label("stddev"))

PARAMETERIZED_AGGREGATES = dict(
    validate=dict(cardinality=lambda p: p in ["resource_id", "user_id", "project_id"]),
    compute=dict(cardinality=lambda p: func.count(distinct(getattr(models.Resource, p))).label("cardinality/%s" % p)),
)

AVAILABLE_CAPABILITIES = {
    "meters": {"query": {"simple": True, "metadata": True}},
    "resources": {"query": {"simple": True, "metadata": True}},
    "samples": {"query": {"simple": True, "metadata": True, "complex": True}},
    "statistics": {
        "groupby": True,
        "query": {"simple": True, "metadata": True},
        "aggregation": {
            "standard": True,