Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-14806: bring demo to standards #20

Merged
merged 20 commits into from Aug 9, 2018
Merged

DM-14806: bring demo to standards #20

merged 20 commits into from Aug 9, 2018

Conversation

SimonKrughoff
Copy link
Contributor

This also takes care of: DM-15044

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things need fixing but it looks great. Thank you.

tests/SConscript Outdated
@@ -0,0 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConscript.tests()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add pyList=[] argument so auto file detection is turned on? Then add a setup.cfg so that we can flake8 the python files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think.


import unittest

from lsst.utils import tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idiom we use is import lsst.utils.tests and then be explicit below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


from lsst.utils import tests

executable_dir = 'bin'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please determine this relative to this test file so that the tests can run from outside the demo root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean determine the absolute path, right?

Copy link
Member

@timj timj Jul 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean:

executable_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "bin")

You might need to include os.path.abspath()and os.path.normpath() as well.

@@ -0,0 +1,2 @@
@LSST BUILD@ &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file needed? I don't have one in daf_butler and everything works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo culted from ci_lsst.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop it. We don't use the build files any more.

@@ -0,0 +1 @@
setupRequired(obs_sdss)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add utils dependency (you use it in the tests) along with python and sconsUtils.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I did this.

vecs.append(v)

for vals in zip(*vecs):
print(' '.join([str(el) for el in vals]))
print(' '.join(['{0:.12g}'.format(el) if issubclass(el.dtype.type, np.floating) else str(el) for el in vals]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a comment before this line

SConstruct Outdated
@@ -0,0 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConstruct("lsst_dm_stack_demo")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add disableCc since we don't need a C++ compiler.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I have two comments:

  • check_astrometry is not being run but we suggest in the README that it should be run. If it is meant to be run we should run it.
  • Now that we are building with scons we should fix up the shebang and move the python files to bin.src.
  • The python scripts in bin/ are not picked up by flake8 because they do not have .py extensions. Moving them to bin.src requires we put the .py extensions on so that will solve this problem.

.travis.yaml Outdated
language: python
matrix:
include:
- python: '2.7'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the 2.7 and 3.5 stuff.

sudo: false
language: python
matrix:
  include:
    - python: '3.6'
      install:
      - pip install flake8
      script: flake8

is sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.travis.yaml Outdated
- python: '3.6'
install:
- pip install flake8
script: flake8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

addopts = --flake8
flake8-ignore = E133 E226 E228 N802 N803 N806
processCcd.py ALL
andConfig.py ALL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import lsst.utils.tests
from lsst.utils import getPackageDir

package_root = getPackageDir('obs_test')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's open to debate whether it's best to use getPackageDir or use this test file location as the reference. I tend to prefer the latter but I'm fine with the former if that's the way you want to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to leave it the way it is. If you hate it, let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It had better be asking for lsst_dm_stack_demo package location though 😉 -- although as you've written it you are making my case for using __file__.

@@ -0,0 +1 @@
build_lsst @PRODUCT@ @VERSION@ @REPOVERSION@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.



if __name__ == "__main__":
lsst.utils.tests.init()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary. We are not doing any tests that leak files or memory (and it's not run by pytest because there is no setup_module equivalent.

"""Test demo"""
self.assertExecutable("demo.sh",
root_dir=executable_dir,
args=["--small"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to use --small here? How do we ever test with large?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to leave as is for now as I don't know how this will be dealt with down the road.

setup.cfg Outdated
@@ -0,0 +1,10 @@
[flake8]
max-line-length = 110
ignore = E133, E226, E228, N802, N803
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add N806.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@timj
Copy link
Member

timj commented Jul 13, 2018

Probably should update the REAME as well.

@@ -0,0 +1,3 @@
# -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConscript.shebang()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline

@timj
Copy link
Member

timj commented Jul 17, 2018

@SimonKrughoff I rebased this branch and did a test build on Jenkins. It failed the astrometry check:

1112 sources in camcol : 4
1112 Sources in reference visit : 4192
1264 sources in camcol :  4
Visit : 6377 750 matches found
Median value of the astrometric scatter - all magnitudes: 169.760284819 mas
Astrometric scatter (median) - mag < 19.5 : 102.698862873 mas
Median astrometric scatter 102.7 mas is larger than reference : 100.0 mas 

See https://ci.lsst.codes/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/28217/pipeline/46

@timj
Copy link
Member

timj commented Jul 17, 2018

It also looks like check_astrometry tries to make a plot and this fails because $DISPLAY is not set on Jenkins.

@RobertLuptonTheGood
Copy link
Contributor

RobertLuptonTheGood commented Jul 18, 2018 via email

@timj
Copy link
Member

timj commented Jul 18, 2018

The plots aren't protected by anything. It always seems to make the PNG. The fix is easy in that we just need to run with a command line option --no-plot or something. More important is that the check_astrometry routine doesn't return any information on pass/fail so the script exit status can't be reported to the test harness.

@wmwv
Copy link
Contributor

wmwv commented Jul 18, 2018

  • The key issue is that the default matplotlib on the Jenkins nodes assumes a backend that the default Jenkins nodes don't actually have.

  • The import matplotlib.pylab as plt line should be moved from a module-level import to be within def plotAstrometry function.

  • main could be updated to not plot by default. We're not actually looking at or saving the plot.

def main(repo, runs, fields, ref, ref_field, camcol, filter, plot=False):
    """Main executable.

    """

    struct = loadAndMatchData(repo, runs, fields, ref, ref_field, camcol, filter)
    mag = struct.mag
    dist = struct.dist
    match = struct.match
    checkAstrometry(mag, dist, match)
    if plot:
        plotAstrometry(mag, dist, match)

@wmwv
Copy link
Contributor

wmwv commented Jul 18, 2018

Plots should all be controlled by lsstDebug (for now), so this sounds like an easy fix.

Can you remind me where this policy is described and if there is a snippet of the recommended wrapper code to implement this?

I agree with using lsstDebug for plotting in all of the science pipelines algorithmic code, but it's less clear to me that things like this demo that are trying demonstrate the full capabilities and meant to be run both in test environments and by an end user should require using lsstDebug to set up a plot.

@RobertLuptonTheGood
Copy link
Contributor

RobertLuptonTheGood commented Jul 18, 2018 via email

@timj
Copy link
Member

timj commented Jul 18, 2018

@wmwv I think your proposal agrees with mine and looks fine. We do need to set exit status if the astrometry test fails, although I'm not sure if anyone has noticed that this test is failing and what the right answer really is (and whether it matters that @SimonKrughoff changed the filter for the astrometry test to make it work with --small).

@timj
Copy link
Member

timj commented Jul 18, 2018

I've made some tweaks and it now runs fine on Jenkins and fails because 102 > 100. https://ci.lsst.codes/blue/organizations/jenkins/stack-os-matrix/detail/stack-os-matrix/28221/tests

It's for someone else to decide that 102 mas is fine.

@jdswinbank
Copy link
Contributor

If I understand the above (having only just skimmed it), this doesn't represent a regression in the astrometry — we were already hitting 102 mas, it's just that we didn't previously notice because we weren't running the test. Given that, I don't think we should wait for a judgement on whether that's acceptable before merging: set the test threshold so that it passes, and at least that means we'll catch it if gets worse. If you're nervous about the absolute value, make a ticket to request that @TallJimbo or @ebellm take a look.

@timj
Copy link
Member

timj commented Jul 18, 2018

This is indeed the first time we've set exit status and would notice a problem. Digging deeper the difference is the change in filter that @SimonKrughoff had to add to the check program to make it work with --small. With the r filter:

CameraMapper INFO: Loading exposure registry from /Users/timj/work/lsstsw3/build/lsst_dm_stack_demo/input/registry.sqlite3
777 sources in camcol : 4
777 Sources in reference visit : 4192
892 sources in camcol :  4
Visit : 6377 576 matches found
Median value of the astrometric scatter - all magnitudes: 103.87098207092725 mas
Astrometric scatter (median) - mag < 19.5 : 85.26176053780722 mas
Ok.

and with the i filter currently being used:

CameraMapper INFO: Loading exposure registry from /Users/timj/work/lsstsw3/build/lsst_dm_stack_demo/input/registry.sqlite3
1112 sources in camcol : 4
1112 Sources in reference visit : 4192
1264 sources in camcol :  4
Visit : 6377 750 matches found
Median value of the astrometric scatter - all magnitudes: 169.76028481841527 mas
bin.src/check_astrometry.py:226: RuntimeWarning: invalid value encountered in less
  idxs = np.where(np.asarray(mag) < good_mag_limit)
Astrometric scatter (median) - mag < 19.5 : 102.6988628735584 mas
Median astrometric scatter 102.7 mas is larger than reference : 100.0 mas 

I'll force this to 105mas for this filter so it will pass.

@timj
Copy link
Member

timj commented Jul 18, 2018

With these changes the demo runs on Jenkins as a standard eups package and passes tests. It now doesn't work the old way (it could do with some tweaking to the demo script) but it's not clear we need it to since we will be removing the special case running of demo in Jenkins.

@@ -14,7 +14,7 @@ Usage
To run the example, do::

$ source $LSST_HOME/loadLSST.sh
$ setup obs_sdss
$ setup -r .
Copy link
Member

@timj timj Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to decide whether the instructions then say "run scons" or whether they stay as they are and we make demo.sh look in ../bin.src/ for the Python code.

@SimonKrughoff SimonKrughoff merged commit 13a6dfb into master Aug 9, 2018
@ktlim ktlim deleted the tickets/DM-14806 branch August 25, 2018 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants