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

[experimental] plugin: add bank info lookup helper function #371

Closed

Conversation

cmoussa1
Copy link
Member

Problem

There are multiple spots in the plugin code where we need to look up user/bank information, and the code isn't super easy to read because a map iterator needs to be declared and used to look up the information in a map. IMHO, It might be easier to read and understand what is going on if this lookup was moved to a helper function.


This PR is just a proposal to see if others would agree that this might be an improvement - if others feel it looks/reads better as before, then I can just close this. 🙂 It creates a helper function, get_bank_info (), that accepts a bank_info map struct iterator, userid, and a bank parameter and performs this lookup in the map. It returns a pair: a return code as well as the iterator to the user/bank map.

In the spots where this new helper function is called, the same logic is retained that handles validating the user/bank information passed in, i.e rejecting the job or raising a job exception because the user/bank information passed in cannot be validated.

It might also be helpful to have a general validation function like this as a result of the conversation in flux-framework/flux-core#5409 since there's talk of potentially having a callback for job updates; it could be helpful to just call this function. 🤷‍♂️

@cmoussa1 cmoussa1 added the improvement Upgrades to an already existing feature label Aug 30, 2023
Problem: There are multiple spots in the plugin code where we need to
look up user/bank information, and the code isn't super easy to read
because a map iterator needs to be declared and used to look up the
information in a map. It might be easier to read and understand what is
going on if this lookup was moved to a helper function.

Create a helper function, get_bank_info (), that accepts a bank_info
map struct iterator, userid, and a bank parameter and performs this
lookup in the map. It returns a pair: a return code as well as the
iterator to the user/bank map.

In the spots where this new helper function is called, the same logic
is retained that handles validating the user/bank information passed
in, i.e rejecting the job or raising a job exception because the
user/bank information passed in cannot be validated.
@cmoussa1 cmoussa1 force-pushed the add.bank-info.lookup.function branch from d308de6 to aa55917 Compare August 31, 2023 15:38
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #371 (b1aef39) into master (c204063) will decrease coverage by 0.26%.
Report is 2 commits behind head on master.
The diff coverage is 66.66%.

❗ Current head b1aef39 differs from pull request most recent head aa55917. Consider uploading reports for the commit aa55917 to get more accurate results

@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
- Coverage   81.29%   81.03%   -0.26%     
==========================================
  Files          20       20              
  Lines        1358     1366       +8     
==========================================
+ Hits         1104     1107       +3     
- Misses        254      259       +5     
Files Changed Coverage Δ
src/plugins/mf_priority.cpp 78.44% <66.66%> (-0.84%) ⬇️

@cmoussa1
Copy link
Member Author

Think I'm gonna close this PR; I'm finding the helper function I wrote pretty useful (with some very slight adjustments), so gonna paste it as a commit to another PR later.

@cmoussa1 cmoussa1 closed this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Upgrades to an already existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant