Skip to content

Commit

Permalink
Added/updated few more files.
Browse files Browse the repository at this point in the history
Standard COPYRIGHT/LICENSE copied from templates. Few other files
updated from templates too. Python code needed small cleanup to pass
flake8.
  • Loading branch information
andy-slac committed Sep 27, 2018
1 parent 9ffcca7 commit 62e2248
Show file tree
Hide file tree
Showing 20 changed files with 892 additions and 89 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sudo: false
language: python
matrix:
include:
- python: '3.6'
install:
- 'pip install flake8'
script:
- flake8
2 changes: 2 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright 2017-2018 The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory
Copyright 2018 University of Washington
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions README.md

This file was deleted.

12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
########
dax_ppdb
########

``dax_ppdb`` is a package in the `LSST Science Pipelines <https://pipelines.lsst.io>`_.

This package provides a Python interface for the Prompt Products Database (PPDB).
Its initial version was developed primarily for performance testing of various
implementation options as a part of the ``lsst-dm/l1dbproto`` package. Several
modules/classes were moved to this package and renamed. It is expected that
this implementation will further evolve to support features necessary for the
Alert Production Pipeline.
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- python -*-
from lsst.sconsUtils import scripts
# Python-only package
scripts.BasicSConstruct("dax_ppdb", disableCc=True)
10 changes: 10 additions & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Doxygen products
html
xml
*.tag
*.inc
doxygen.conf

# Sphinx products
_build
py-api
3 changes: 3 additions & 0 deletions doc/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConscript.doc()
13 changes: 13 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Sphinx configuration file for an LSST stack package.
This configuration only affects single-package Sphinx documenation builds.
"""

from documenteer.sphinxconfig.stackconf import build_package_configs
import lsst.dax.ppdb


_g = globals()
_g.update(build_package_configs(
project_name='dax_ppdb',
version=lsst.dax.ppdb.version.__version__))
Empty file added doc/doxygen.conf.in
Empty file.
12 changes: 12 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##############################
dax_ppdb documentation preview
##############################

.. This page is for local development only. It isn't published to pipelines.lsst.io.
.. Link the index pages of package and module documentation directions (listed in manifest.yaml).
.. toctree::
:maxdepth: 1

lsst.dax.ppdb/index
38 changes: 38 additions & 0 deletions doc/lsst.dax.ppdb/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. py:currentmodule:: lsst.dax.ppdb
.. _lsst.dax.ppdb:

#############
lsst.dax.ppdb
#############

.. Paragraph that describes what this Python module does and links to related modules and frameworks.
.. .. _lsst.dax.ppdb-using:
.. Using lsst.dax.ppdb
.. ===================
.. toctree linking to topics related to using the module's APIs.
.. .. toctree::
.. :maxdepth: 1
.. _lsst.dax.ppdb-contributing:

Contributing
============

``lsst.dax.ppdb`` is developed at https://github.com/lsst/dax_ppdb.
You can find Jira issues for this module under the `dax_ppdb <https://jira.lsstcorp.org/issues/?jql=project%20%3D%20DM%20AND%20component%20%3D%20dax_ppdb>`_ component.

.. If there are topics related to developing this module (rather than using it), link to this from a toctree placed here.
.. _lsst.dax.ppdb-pyapi:

Python API reference
====================

.. automodapi:: lsst.dax.ppdb
:no-main-docstr:
:no-inheritance-diagram:
12 changes: 12 additions & 0 deletions doc/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Documentation manifest.

# List of names of Python modules in this package.
# For each module there is a corresponding module doc subdirectory.
modules:
- "lsst.dax.ppdb"

# Name of the static content directories (subdirectories of `_static`).
# Static content directories are usually named after the package.
# Most packages do not need a static content directory (leave commented out).
# statics:
# - "_static/dax_ppdb"
23 changes: 22 additions & 1 deletion python/lsst/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
import pkgutil
# This file is part of dax_ppdb.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pkgutil, lsstimport
__path__ = pkgutil.extend_path(__path__, __name__)
23 changes: 22 additions & 1 deletion python/lsst/dax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
import pkgutil
# This file is part of dax_ppdb.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pkgutil, lsstimport
__path__ = pkgutil.extend_path(__path__, __name__)
35 changes: 10 additions & 25 deletions python/lsst/dax/ppdb/ppdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@
"""Module defining Ppdb class and related methods.
"""

#--------------------------------
# Imports of standard modules --
#--------------------------------
__all__ = ["PpdbConfig", "Ppdb"]

from collections import namedtuple
from contextlib import contextmanager
from datetime import datetime
import logging
import numpy as np
import os

#-----------------------------
# Imports for other modules --
#-----------------------------
import lsst.geom as geom
import lsst.afw.table as afwTable
import lsst.pex.config as pexConfig
Expand All @@ -45,9 +41,6 @@
from sqlalchemy.pool import NullPool
from . import timer, ppdbSchema

#----------------------------------
# Local non-exported definitions --
#----------------------------------

_LOG = logging.getLogger(__name__.partition(".")[2]) # strip leading "lsst."

Expand All @@ -64,7 +57,6 @@ class Timer(object):
See also :py:mod:`timer` module.
"""

def __init__(self, name, do_logging=True, log_before_cursor_execute=False):
self._log_before_cursor_execute = log_before_cursor_execute
self._do_logging = do_logging
Expand Down Expand Up @@ -112,13 +104,11 @@ def _split(seq, nItems):
yield seq[:nItems]
del seq[:nItems]

#------------------------
# Exported definitions --
#------------------------

# Information about single visit
Visit = namedtuple('Visit', 'visitId visitTime lastObjectId lastSourceId')


@contextmanager
def _ansi_session(engine):
"""Returns a connection, makes sure that ANSI mode is set for MySQL
Expand All @@ -135,10 +125,6 @@ def _data_file_name(basename):
"""
return os.path.join(getPackageDir("dax_ppdb"), "data", basename)

#---------------------
# Class definition --
#---------------------


class PpdbConfig(pexConfig.Config):

Expand Down Expand Up @@ -258,10 +244,6 @@ def __init__(self, config, afw_schemas=None):
afw_schemas=afw_schemas,
prefix=self.config.prefix)

#-------------------
# Public methods --
#-------------------

def lastVisit(self):
"""Returns last visit information or `None` if visits table is empty.
Expand Down Expand Up @@ -376,11 +358,14 @@ def getDiaObjects(self, pixel_ranges):
query = sql.select(columns)

if self.config.diaobject_index_hint:
query = query.with_hint(table, 'index_rs_asc(%(name)s "{}")'.format(self.config.diaobject_index_hint))
val = self.config.diaobject_index_hint
query = query.with_hint(table, 'index_rs_asc(%(name)s "{}")'.format(val))
if self.config.dynamic_sampling_hint > 0:
query = query.with_hint(table, 'dynamic_sampling(%(name)s {})'.format(self.config.dynamic_sampling_hint))
val = self.config.dynamic_sampling_hint
query = query.with_hint(table, 'dynamic_sampling(%(name)s {})'.format(val))
if self.config.cardinality_hint > 0:
query = query.with_hint(table, 'FIRST_ROWS_1 cardinality(%(name)s {})'.format(self.config.cardinality_hint))
val = self.config.cardinality_hint
query = query.with_hint(table, 'FIRST_ROWS_1 cardinality(%(name)s {})'.format(val))

# build selection
exprlist = []
Expand All @@ -394,7 +379,7 @@ def getDiaObjects(self, pixel_ranges):

# select latest version of objects
if self.config.dia_object_index != 'last_object_table':
query = query.where(table.c.validityEnd == None)
query = query.where(table.c.validityEnd == None) # noqa: E711

_LOG.debug("query: %s", query)

Expand Down
Loading

0 comments on commit 62e2248

Please sign in to comment.