Skip to content

Conversation

@spacetimeengineer
Copy link
Contributor

Future releases of echopype may accommodate cases where the user is not required to provide sonar model numbers. We have here a simple checker to do that.

-Added model checkers for EK60 and EK80 sonar models.

spacetimeengineer and others added 3 commits October 25, 2024 15:33
Future releases of echopype may accommodate cases where the user is not required to provide sonar model numbers. We have here a simple checker to do that.

-Added model checkers for EK60 and EK80 sonar models.
Copy link
Contributor Author

@spacetimeengineer spacetimeengineer left a comment

Choose a reason for hiding this comment

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

It didn't seem appropriate to put this function in the class, at least not yet but the file did seem a good place to put this.

@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 22.00000% with 39 lines in your changes missing coverage. Please review.

Project coverage is 79.84%. Comparing base (9f56124) to head (c7c4f94).
Report is 211 commits behind head on main.

Files with missing lines Patch % Lines
echopype/convert/sonar_model_checker.py 20.40% 39 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1399      +/-   ##
==========================================
- Coverage   83.52%   79.84%   -3.68%     
==========================================
  Files          64       20      -44     
  Lines        5686     3161    -2525     
==========================================
- Hits         4749     2524    -2225     
+ Misses        937      637     -300     
Flag Coverage Δ
unittests 79.84% <22.00%> (-3.68%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@spacetimeengineer
Copy link
Contributor Author

I do not have coverage because I haven't wrote the tests yet. Ill be sure to get those over ASAP.

Added test cases for EK60 and EK80 raw parser functions to validate their identification of echosounder types through raw data alone.
The test failed because a proper path wasn't provided to them. This commit should fix that.
I forgot to import the outside-of-class functions in the __init__. Consider this fixed.
- Added notes about the potential need to remove sudo privileges for some users.
- Improved tests by adding an exception handler for key errors, returning False when encountered.
Syntax error fixed.
The 'e' variable commonly used in error handling was not utilized, so I removed it. This change caused tests to fail, prompting its removal.
@leewujung leewujung self-requested a review October 30, 2024 20:50
@leewujung
Copy link
Member

@spacetimeengineer: is this PR ready to review? If not just ping me when you think it's ready. Thanks!

@spacetimeengineer
Copy link
Contributor Author

spacetimeengineer commented Oct 30, 2024 via email

@spacetimeengineer
Copy link
Contributor Author

spacetimeengineer commented Oct 30, 2024 via email

@spacetimeengineer
Copy link
Contributor Author

On my fork I have having these errors pop up and I don't fully understand them yet.

minioci-build
Username and password required
http-build
The job was canceled because "minioci" failed.
http-build
The operation was canceled.

@leewujung
Copy link
Member

Oh I see - you can disable these builds since they will be run on the main repo (here).

@spacetimeengineer
Copy link
Contributor Author

Thanks, that’s great! Let me know if there's anything else I need to do. Just a heads-up—this PR is part of a series of similar checkers for other models. I don’t think this approach will be very effective until all models are covered, and even then, I’d recommend keeping the sonar_model parameter as an option at least. Let me know if this seems a worthwhile feature.

@spacetimeengineer spacetimeengineer self-assigned this Nov 1, 2024
@spacetimeengineer spacetimeengineer added the enhancement This makes echopype better label Nov 1, 2024
@leewujung
Copy link
Member

I haven't had a chance to check the code, but from a quick glance this is fine since it is not a gigantic PR.

I think it would be better to always keep the sonar_model argument, and spit out an error if what they specified mismatches with what are contained in the files (i.e. I don't think we should "make it work" under the hood for users if they specify the wrong parameters). It is part of making sure people are aware of what operations they are trying to perform, since some people may be new to echosounder processing.

@spacetimeengineer
Copy link
Contributor Author

spacetimeengineer commented Nov 1, 2024

I agree with your perspective. My intention was not to remove the sonar model parameter, (it only helps echopype users to provide more information) but rather to explore the possibility of allowing future releases to parse the sonar model directly from the raw data. This approach could enhance the intelligence of the base parser. While it wouldn't be fully effective until all model checkers are developed, it would allow us to clarify what the sonar model is not, rather than just asserting what it is. I figured if the user makes a mistake providing the sonar_model then the more intelligent base parser could provide a warning and ask the user if they want to process with the true parsed sonar_model value or some kind of override.

Need to import these functions.
Comment on lines -84 to +100
Docker image on Docker hub.
Docker image on Docker hub. There’s no need to pull directly from Docker Hub, as the scripts below will handle that for you. For Linux Users: If you run into an issue where accessing the Docker daemon requires sudo privileges, which may not suit your environment, you can adjust your settings to allow non-root access to Docker:

```shell
sudo groupadd docker
```

Add the current user to the Docker group
```shell
sudo gpasswd -a $USER docker
```

Restart the docker daemon
```shell
sudo service docker restart
```

You might also need to restart your computer if the steps above don't resolve the issue.
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this to a new PR since it's under a completely different topic? I think there we could update the contributing guide from you and others as you're fresh from setting up a dev environment and may want to add other details. Thanks!

Comment on lines 38 to 42
with RawSimradFile(raw_file, "r", storage_options=storage_options) as fid:
config_datagram = fid.read(1)
config_datagram["timestamp"] = np.datetime64(
config_datagram["timestamp"].replace(tzinfo=None), "[ns]"
)
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why you are accessing the timestamp here.

See Gavin's #494 (comment) that I think would be useful here to check the format without using the full blown parser. Implementing that into the checker would address #494 too in this PR.

Copy link
Member

@leewujung leewujung left a comment

Choose a reason for hiding this comment

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

@spacetimeengineer : Thanks for the PR! I added some inline comments above, and have a few structural comments below:


I think the sonar model checking code should be in a separate module (say convert/sonar_model_checker.py), specified in core.py like the parser and set_group functions, and called in open_raw to check the matches between user-specified sonar_model type and the actual file content. The checks can happen right after the _check_file call that checks file existence and before the parser is called to parse the full data file. This way the functions will be easier to maintain since they don't get wrapped in the parser child classes but with different method names.

Similarly, I think the tests for these checker functions can be in a different module tests/convert/test_sonar_model_checker.py, to keep these tests isolated from the actual parsing of data file content.


The is_{SONAR_MODEL} functions you added are of 2 types:

  1. One checks for just the file extension name: is_AD2CP, is_AZFP6 -- this check already exists in functions validate_ext and validate_azfp_ext in core.py.
  2. One takes a peek "under the hood" to see if the data actually fits the expected config format: is_AZFP, is_EK60, is_ER60, is_EK80 -- we need these. Note that the older Simrad format was also used for many other echosounder models, not just EK60 and ER60. The same for the newer Simrad format. We can improve what's in core.py so that the same blocks using the same parser/setgrouper don't need to be repeated. I'll write a small issue for that -- we just need a mechanism to select the right key in the main SONAR_MODELS dict. -- in fact, this is just #995.

For paths to test files, please use fixtures:

@pytest.fixture(scope="session")
def test_path():

This will make maintenance and upcoming migration of the testing infrastructure smoother.

@spacetimeengineer
Copy link
Contributor Author

@leewujung Acknowledged. Ill begin putting in these changes.

@leewujung leewujung marked this pull request as draft December 30, 2024 19:40
@spacetimeengineer spacetimeengineer marked this pull request as ready for review March 17, 2025 17:23
@spacetimeengineer
Copy link
Contributor Author

@leewujung My team has asked me to get this PR merged because the sonar-checking code is essential for something they’re working on. I suggested moving the code to their library, but they couldn’t do so due to large dependencies. I understand their perspective, but I don’t want to impose this on you or anyone. If there’s anything I can do to improve this PR, please let me know.

@leewujung
Copy link
Member

@spacetimeengineer : I was never sure if the requested changes were done since my comment back in Nov, and if not, your reasoning. I quickly checked it and think many of my requests were not included.

Pinging @jmjech since I can't merge code without discussions.

Note I am not able to work on this until next week due to other responsibilities.

@spacetimeengineer
Copy link
Contributor Author

@leewujung I think there may have been some miscommunication, and I take full responsibility for that. Here’s my understanding: Originally, this PR aimed to enhance the functionality of the echodata object, but you pointed out that it wasn’t necessary (which I agreed with after your explanation). However, there were still potential uses for the code, either for future features or as utility functions.

At that point, I understood that the PR’s purpose had shifted, so I may not have fully met some of your initial requirements since I was no longer modifying the echodata object’s algorithm but perhaps you were trying to help me get these sonar checking functions in the main code. (Of course, if you’d like me to do still that, I can.) Later, the intentions of this PR changed again when I realized someone else needed these functions but found the dependencies too large. Given that, it didn’t seem entirely unreasonable to resubmit.

This is a small PR—it only includes the sonar-checking functions in the specified files, along with the corresponding tests which I believe work. Thats all it was meant to be. So the only requirements from you I could meet was the location of the code and the files names you specified. If I missed anything, let me know, and I’ll fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This makes echopype better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants