GEUS-Glaciology-and-Climate / pypromice

Process AWS data from L0 (raw logger) through Lx (end user)
https://pypromice.readthedocs.io
GNU General Public License v2.0
12 stars 4 forks source link

[JOSS review] Command given to run tests is failing. #138

Closed simonrp84 closed 1 year ago

simonrp84 commented 1 year ago

Hello, In the quick install guide the command given to run the unittests (python -m unittest discover pypromice) throws an error:

(base) C:\Users\simon\pypromice>python -m unittest discover pypromice
Traceback (most recent call last):
  File "C:\Users\simon\miniconda3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\simon\miniconda3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\simon\miniconda3\lib\unittest\__main__.py", line 18, in <module>
    main(module=None)
  File "C:\Users\simon\miniconda3\lib\unittest\main.py", line 100, in __init__
    self.parseArgs(argv)
  File "C:\Users\simon\miniconda3\lib\unittest\main.py", line 124, in parseArgs
    self._do_discovery(argv[2:])
  File "C:\Users\simon\miniconda3\lib\unittest\main.py", line 244, in _do_discovery
    self.createTests(from_discovery=True, Loader=Loader)
  File "C:\Users\simon\miniconda3\lib\unittest\main.py", line 154, in createTests
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "C:\Users\simon\miniconda3\lib\unittest\loader.py", line 346, in discover
    raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: 'pypromice'

Could you please investigate what's happening there? I tried a few different combinations and haven't had any luck working around the error.

PennyHow commented 1 year ago

Hi @simonrp84,

These are the following steps I did to make the unit testing work.

conda create --name pypromice-test python=3.8
conda activate pypromice-test
pip install --upgrade git+http://github.com/GEUS-Glaciology-and-Climate/pypromice.git
python -m unittest discover pypromice

And this should be the output of those unit tests:

.
AWS object initialising...
-----> No msg_lat or msg_lon for test_raw1.txt
L0 data successfully loaded from test_raw1.txt
-----> No msg_lat or msg_lon for test_raw_SlimTableMem1.txt
L0 data successfully loaded from test_raw_SlimTableMem1.txt
L0 data successfully loaded from test_raw_transmitted1.txt
Commencing 1-boom processing...
Level 1 processing...
Level 2 processing...
Unable to download flag file, using local file: local/flags/TEST1.csv
No flag file to read.
Unable to download adjustment file, using local file: local/adjustments/TEST1.csv
No adjustment file to read.
Level 3 processing...
Resampling to 10 minute
....300234061165160-36820 (binary) Promice 2015 summer message
..
----------------------------------------------------------------------
Ran 7 tests in 3.866s

OK

This is as documented in the installation guide. Can you walk us through specifically how you are getting your error? Are you performing the unit testing with the pypromice package installed in the Python environment or from source?

simonrp84 commented 1 year ago

Hi, I can confirm that the commands you list here are working OK.

conda create --name pypromice-test python=3.8
conda activate pypromice-test
pip install --upgrade git+http://github.com/GEUS-Glaciology-and-Climate/pypromice.git
python -m unittest discover pypromice

But those are slightly different from what's written in the installguide, which are:

conda create --name pypromice python=3.8
conda activate pypromice
conda install xarray pandas pathlib
conda install -c conda-forge netCDF4
git clone git@github.com:GEUS-Glaciology-and-Climate/pypromice.git
cd pypromice/
pip install .
python -m unittest discover pypromice

These commands do not work unless I'm in the pypromice source directory. Perhaps you could edit the installguide to mirror your commands in the comment above? This may be some operating system specific issue, as I'm only able to test on Windows at the moment.

PennyHow commented 1 year ago

Yes, editing the installation guide is a good idea - saves confusion. We can do that no problem.

simonrp84 commented 1 year ago

Looks good to me, thanks for the rapid modifications!