-
Notifications
You must be signed in to change notification settings - Fork 118
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
Replace hocload.sh
with std::filesystem
utils
#3293
base: master
Are you sure you want to change the base?
Conversation
const std::vector<std::string>& paths) { | ||
namespace fs = std::filesystem; | ||
for (const auto& path: paths) { | ||
for (const auto& entry: fs::directory_iterator(path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this returns the same ordering as egrep '^func|^proc|^begintemplate' $p/*.oc $p/*.hoc
(the C++ standard does not specify ordering, so I guess it depends on the library?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entries may not be sorted at all, whereas the shell bit you point out first goes through all .oc
files, followed by all .hoc
.
Since only the first match is used, would one expect multiple definitions of the same entity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entries may not be sorted at all
Indeed! I changed the implementation so it's actually sorted, it should even respect the locale now since that's what the POSIX glob
does (had a whole rant ready about locales, but it turns out it's surprisingly simple to use, at least for this usecase :)
Since only the first match is used, would one expect multiple definitions of the same entity?
I'd expect it to throw an error in case of multiple definitions, or provide some mechanism to disambiguate, but I don't think there is anything of the sort, so I just sought to replicate the existing behavior.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3293 +/- ##
==========================================
- Coverage 67.07% 67.04% -0.03%
==========================================
Files 571 571
Lines 111055 111097 +42
==========================================
Hits 74488 74488
- Misses 36567 36609 +42 ☔ View full report in Codecov by Sentry. |
This comment has been minimized.
This comment has been minimized.
✔️ 6a3f8d8 -> Azure artifacts URL |
Model 150245 from modelDB fails (see https://github.com/neuronsimulator/nrn-modeldb-ci/actions/runs/12369627580/job/34521930207), but I am 99.99% sure it's not related since it fails on the nightly as well (see https://github.com/neuronsimulator/nrn-modeldb-ci/actions/runs/12361469702/job/34498702435). |
✔️ 253637f -> Azure artifacts URL |
✔️ 0bc2c1d -> Azure artifacts URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm of two minds about this. On the one hand, if the change does not affect behavior, I'm fine with it. On the other hand, I don't want to spend any time on it. This supports an old feature of hoc for the functions load_func
, load_proc
, and load_template
. see, e.g. https://nrn.readthedocs.io/en/latest/hoc/programming/dynamiccode.html#load_func which probably can't be removed but is practically superseded by the less complex, easier to understand, and very commonly used load_file
. My prejudice is not to spend too much time on hoc development (python is so much more useful!) but only to keep it maintained. This pr perhaps simplifies maintenance so I'm approving. But let's first be sure it passes nrn-modeldb-ci
Quality Gate passedIssues Measures |
✔️ 609d27f -> Azure artifacts URL |
hoc_load
seems to be doing the following:proc
,func
,begintemplate
gargstr
) is a defined symbol in the current scopehocload.sh
with 3 args: the keyword, the symbol name, andhoc_pid
. This script seems togrep
all HOC files in${PWD}
,${HOC_LIBRARY_PATH}
for the patternfunc|proc|begintemplate
, stores them in the temp filenames
, then usessed
to find out whether there is a matching symbol in some file. If there is, it echoes the first match, and returns 0, and if there aren't any matches, it returns 1.hoc_Load_file
I've replaced most of the above using
std::filesystem
, though I am not sure whether the logic of returning the first match is right in the first place, but nevertheless I tried replicating the existing behavior as closely as possible.