PolarGeospatialCenter / imagery_utils

Other
34 stars 10 forks source link

how to use tests? #14

Open 7yl4r opened 4 years ago

7yl4r commented 4 years ago

I've tried running the tests included here with pytest and it was unable to find any tests. I then tried running with nosetests and I get the following error(s):

tylar@tylar-Latitude-XT3:/media/tylar/filestore/imars/imagery_utils$ nosetests
EEEEEEEEEEEEEEE
======================================================================
ERROR: test_pansharpen (func_test_pansharpen.TestPanshFunc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/media/tylar/filestore/imars/imagery_utils/tests/func_test_pansharpen.py", line 27, in setUp
    os.makedirs(self.dstdir)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/bin/testdata'

[...]

======================================================================
ERROR: test_spatial_ref (unit_test_utils.TestUtils)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/media/tylar/filestore/imars/imagery_utils/tests/unit_test_utils.py", line 20, in setUp
    self.output = os.path.join(test_dir, 'output')
NameError: global name 'test_dir' is not defined

----------------------------------------------------------------------
Ran 15 tests in 0.079s

FAILED (errors=15)

How can I use these tests?

clairecporter commented 4 years ago

Tylar,

The tests use the python library unittest and are design to help us make sure any new code changes have not caused code regressions and bugs. They require a folder of test data that we cannot commit to the repo because it contains licensed data. I know it is not ideal to be unable to run the tests yourself, but they are intended for development and not for users. We have considered building test data that can be committed, but there has never been a pressing need.

Thanks for using the tools, c

On Sat, Nov 9, 2019 at 8:20 AM Tylar notifications@github.com wrote:

I've tried running the tests included here with pytest and it was unable to find any tests. I then tried running with nosetests and I get the following error(s):

tylar@tylar-Latitude-XT3:/media/tylar/filestore/imars/imagery_utils$ nosetests EEEEEEEEEEEEEEE

ERROR: test_pansharpen (func_test_pansharpen.TestPanshFunc)

Traceback (most recent call last): File "/media/tylar/filestore/imars/imagery_utils/tests/func_test_pansharpen.py", line 27, in setUp os.makedirs(self.dstdir) File "/usr/lib/python2.7/os.py", line 150, in makedirs makedirs(head, mode) File "/usr/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/usr/bin/testdata'

[...]

====================================================================== ERROR: test_spatial_ref (unit_test_utils.TestUtils)

Traceback (most recent call last): File "/media/tylar/filestore/imars/imagery_utils/tests/unit_test_utils.py", line 20, in setUp self.output = os.path.join(test_dir, 'output') NameError: global name 'test_dir' is not defined


Ran 15 tests in 0.079s

FAILED (errors=15)

How can I use these tests?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=AAXRNVHLXFE5O2NYLUWIIXTQS3BJDA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HYFJTNA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXRNVA7JC6GPES3IHEOR6TQS3BJDANCNFSM4JLHJKFQ .

7yl4r commented 4 years ago

I would like to put some work into this to make these tools easier to test with public data. I know how to apply marks and create test suites using pytest and could do this with your tests to mark "licensed_data_needed" tests. This would allow me to add some tests and to connect with continuous integration tools to test compatibility across different versions of python so we can avoid issues like USF-IMARS/wv2-processing#23.

How are the tests here orchestrated in your workflow? Would you be open to a pull request which implements tests using pytest instead?

juntunen commented 4 years ago

Hey Tylar, I'm a developer at PGC who works on a different project. I'd love to know more about how to mark tests the way you describe. I have a rather basic knowledge of pytest, but am not up on its more advanced features. I have the Pragmatic Pub book about pytest, I'll have to see what it says. Thanks! Thomas

On Tue, Nov 12, 2019 at 4:35 PM Tylar notifications@github.com wrote:

I would like to put some work into this to make these tools easier to test with public data. I know how to apply marks and create test suites using pytest and could do this with your tests to mark "licensed_data_needed" tests. This would allow me to add some tests and to connect with continuous integration tools to test compatibility across different versions of python so we can avoid issues like USF-IMARS/wv2-processing#23 https://github.com/USF-IMARS/wv2-processing/issues/23.

How are the tests here orchestrated in your workflow? Would you be open to a pull request which implements tests using pytest instead?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=ADTJP4FRCW7PJEHFF7JNOG3QTMVTJA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED4GDUY#issuecomment-553148883, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTJP4HV7AVMBCKMSF3KENDQTMVTJANCNFSM4JLHJKFQ .

-- The right coordinate system can turn an impossible problem into two really hard problems. -- Charlie Pellerin

Thomas Juntunen GIS Specialist Polar Geospatial Center R280 Learning and Environmental Science 1954 Buford Ave University of Minnesota St. Paul, MN 55108 612-626-0505

7yl4r commented 4 years ago

Hi Thomas! I'm glad to hear there is interest. I can prepare a basic implementation over on my fork and submit a PR with more details. Can you provide more information on how these tests are run currently? I will need to make changes to them but I don't want to break anyone's workflow if possible.

juntunen commented 4 years ago

imagery_utils is Claire Porter's project and you'll have to wait for her to respond about a PR.

For some context, PGC is a tiny research-support group at the University of Minnesota. 3 or 4 of us develop software that's needed for our imagery management purposes. We don't have teams, established testing procedures, continuous integration or any of those niceties. I have tried to develop some unit tests for the project I work on, and the next major iteration will be much more integrated with testing and I hope to leverage the university's CI environment at some point. A thorn in the process we do have, is our imagery is under license and cannot be used for testing in public repos. (Nor would I really want to try and add GB of files to a repo...). But I would like to have a set of tests that I can run in full here, and the appropriate ones would run for anyone else using my stuff. At some point I need to move my UMN GitHub repo to the public one so the folks I work with at NASA can use it and that would be a nice feature for them.

Sorry I can't help you with your specific question, but I would be interested to know more about how the marking you described works.

Thomas

On Wed, Nov 13, 2019 at 12:21 PM Tylar notifications@github.com wrote:

Hi Thomas! I'm glad to hear there is interest. I can prepare a basic implementation over on my fork and submit a PR with more details. Can you provide more information on how these tests are run currently? I will need to make changes to them but I don't want to break anyone's workflow if possible.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=ADTJP4CTAJSD5FIECZWSE6DQTRASNA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED7EORQ#issuecomment-553535302, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTJP4CXBYY3VE4RNFX3XJTQTRASNANCNFSM4JLHJKFQ .

-- The right coordinate system can turn an impossible problem into two really hard problems. -- Charlie Pellerin

Thomas Juntunen GIS Specialist Polar Geospatial Center R280 Learning and Environmental Science 1954 Buford Ave University of Minnesota St. Paul, MN 55108 612-626-0505

7yl4r commented 4 years ago

I am the only "computer guy" here at USF's IMaRS so I can definitely relate to the challenges faced by small groups. I have found Travis CI and pytest very useful even for my personal projects and I hope I can share some highlights that will help ya'll in the same way this PGC code has helped us.

I will be playing with pytest & imagery_utils over the next few weeks but can you also link me to your project? - maybe I can help apply pytest marks there as well. It might make sense to tag or assign me on an issue on your repo or else reach out via email directly: tylarmurray@mail.usf.edu - that way we don't get too off track in this issue thread.

juntunen commented 4 years ago

Hey Tylar, I would if I could, but the UMN GitHub isn't accessible outside the university firewall. That's the main reason I am preparing to move it to public GitHub, probably part of the account you're already accessing. I need to create something resembling docs, or at least a reasonable readme and I would like to figure out a proper setup.py; the IT folks here would like to deploy to my office's users via pip. However, that got sort of derailed in that I have had to make some big changes at the last minute to accommodate switching from a disk-based datastore to a tape system. An important part of my code is to find the imagery the user needs, and we are in the midst of switching. So my imagery retrieval, which was in two parts, one for disk and one for tape, is being merged into a single workflow, for technical reasons. But as soon as it's a bit more stable I can at least send you a tarball if you like. Otherwise I'd be happy to let you know when I get it transferred to the public repo. Thomas

On Wed, Nov 13, 2019 at 1:41 PM Tylar notifications@github.com wrote:

I am the only "computer guy" here at USF's IMaRS so I can definitely relate to the challenges faced by small groups. I have found Travis CI and pytest very useful even for my personal projects and I hope I can share some highlights that will help ya'll in the same way this PGC code has helped us.

I will be playing with pytest & imagery_utils over the next few weeks but can you also link me to your project? - maybe I can help apply pytest marks there as well. It might make sense to tag or assign me on an issue on your repo or else reach out via email directly: tylarmurray@mail.usf.edu - that way we don't get too off track in this issue thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=ADTJP4HGUALXX3P2HJJQEGDQTRJ6RA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED7MKPY#issuecomment-553567551, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTJP4BVLFW6PHARXQ6643TQTRJ6RANCNFSM4JLHJKFQ .

-- The right coordinate system can turn an impossible problem into two really hard problems. -- Charlie Pellerin

Thomas Juntunen GIS Specialist Polar Geospatial Center R280 Learning and Environmental Science 1954 Buford Ave University of Minnesota St. Paul, MN 55108 612-626-0505

clairecporter commented 4 years ago

Hi Tylar,

We would be happy to incorporate new tests into the project. As Thomas mentioned, the team here is small and spread pretty thin, so we are more than happy to accept assistance and very glad to see the tools in use.

The current test are rather haphazard. They are mostly written using unittest which is not easily orchestrated aside from a command line run. There are a few tests that were written by another contributor that are not part of a framework at all. We'd be happy to have you convert any old tests that are reasonable and add new ones in pytest. If I can give you more information, let me know. We can also chat on the phone if that would be more effective.

It looks like you are NSF-funded, in which case I can share our current test data with you. Let me know if that would help.

c

On Tue, Nov 12, 2019 at 4:35 PM Tylar notifications@github.com wrote:

I would like to put some work into this to make these tools easier to test with public data. I know how to apply marks and create test suites using pytest and could do this with your tests to mark "licensed_data_needed" tests. This would allow me to add some tests and to connect with continuous integration tools to test compatibility across different versions of python so we can avoid issues like USF-IMARS/wv2-processing#23 https://github.com/USF-IMARS/wv2-processing/issues/23.

How are the tests here orchestrated in your workflow? Would you be open to a pull request which implements tests using pytest instead?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=AAXRNVFLAMSBFIBKTZJEM5TQTMVTJA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED4GDUY#issuecomment-553148883, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXRNVCIL7S2ACRVEOC4M5LQTMVTJANCNFSM4JLHJKFQ .

clairecporter commented 4 years ago

Note, we did update imagery_utils to python3 compatibility (regarding issue USF-IMARS/wv2-processing#23 https://github.com/USF-IMARS/wv2-processing/issues/23). Let me check in with my team to see if that was rolled out.

On Wed, Nov 13, 2019 at 2:12 PM Claire Porter claire.porter@gmail.com wrote:

Hi Tylar,

We would be happy to incorporate new tests into the project. As Thomas mentioned, the team here is small and spread pretty thin, so we are more than happy to accept assistance and very glad to see the tools in use.

The current test are rather haphazard. They are mostly written using unittest which is not easily orchestrated aside from a command line run. There are a few tests that were written by another contributor that are not part of a framework at all. We'd be happy to have you convert any old tests that are reasonable and add new ones in pytest. If I can give you more information, let me know. We can also chat on the phone if that would be more effective.

It looks like you are NSF-funded, in which case I can share our current test data with you. Let me know if that would help.

c

On Tue, Nov 12, 2019 at 4:35 PM Tylar notifications@github.com wrote:

I would like to put some work into this to make these tools easier to test with public data. I know how to apply marks and create test suites using pytest and could do this with your tests to mark "licensed_data_needed" tests. This would allow me to add some tests and to connect with continuous integration tools to test compatibility across different versions of python so we can avoid issues like USF-IMARS/wv2-processing#23 https://github.com/USF-IMARS/wv2-processing/issues/23.

How are the tests here orchestrated in your workflow? Would you be open to a pull request which implements tests using pytest instead?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PolarGeospatialCenter/imagery_utils/issues/14?email_source=notifications&email_token=AAXRNVFLAMSBFIBKTZJEM5TQTMVTJA5CNFSM4JLHJKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED4GDUY#issuecomment-553148883, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXRNVCIL7S2ACRVEOC4M5LQTMVTJANCNFSM4JLHJKFQ .

7yl4r commented 4 years ago

It looks like you are NSF-funded, in which case I can share our current test data with you. Let me know if that would help.

This would be a great start. My work on this is funded under the NSF South Big Data Hub project "Enhanced 3-D Mapping for Habitat, Biodiversity, and Flood Hazard Assessments of Coastal and Wetland Areas of the Southern US". If I can recreate your tests in full here then I will feel more comfortable making changes knowing that I didn't break anything. I can send FTP upload information or can download data however you recommend. If you want to set up a call or discuss exchanging data further let's start a separate email thread: tylarmurray@mail.usf.edu .

The current test are rather haphazard. They are mostly written using unittest which is not easily orchestrated aside from a command line run. There are a few tests that were written by another contributor that are not part of a framework at all. We'd be happy to have you convert any old tests that are reasonable and add new ones in pytest. If I can give you more information, let me know. We can also chat on the phone if that would be more effective.

If all goes as planned you will continue to be able to run all tests via a bash command and minimal additional setup of the pytest module. I will try marking the two sets of tests separately and change as little as possible. Can you detail the steps for me to recreate all tests? That is: what commands should I use and where I should put the test data?

Once I can reproduce your tests I will modify all to work with pytest & submit a PR. From there I can start adding test-data-less tests that will work with Travis CI and other public users.

7yl4r commented 4 years ago

I'd like to also request an admin "assign" me this issue. It got dangerously close to falling off my radar this week because it doesn't show up in my issues list unless I'm assigned.

7yl4r commented 4 years ago

I now have the test data but cannot run tests sucessfully using the latest python & GDAL. Each test has several different errors. unit_test_taskhandler.py is the only test which passes. What versions of gdal and python are recommended to test the master branch?

[tylar@tylar-pc ~]$ gdal-config --version
3.0.1
[tylar@tylar-pc ~]$ python3 --version
Python 3.7.4

I am wondering if perhaps I should rearrange tests starting from scratch and add in only what is working. I hate to lose work on these tests but I can't port them until I can make them pass.