Skip to content

Conversation

@abhaasgoyal
Copy link

@abhaasgoyal abhaasgoyal commented Jul 1, 2025

Resolves #331

Create a workflow for benchcab not requiring for the user to enter model_output_id anymore. Instead, the user needs to specify which branch should be chosen as the model_output_name, from which benchcab does the necessary workflow.

Uses the new API endpoints from me.org API v3.0.0 (see CABLE-LSM/meorg_client#67 for more details)

@abhaasgoyal abhaasgoyal marked this pull request as draft July 1, 2025 23:29
@codecov
Copy link

codecov bot commented Aug 17, 2025

Codecov Report

❌ Patch coverage is 79.68750% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.60%. Comparing base (8e0d58f) to head (fc4c18b).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/benchcab/utils/meorg.py 27.27% 8 Missing ⚠️
src/benchcab/config.py 93.87% 3 Missing ⚠️
src/benchcab/benchcab.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
+ Coverage   68.28%   69.60%   +1.32%     
==========================================
  Files          21       21              
  Lines        1157     1214      +57     
==========================================
+ Hits          790      845      +55     
- Misses        367      369       +2     

☔ 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.

@abhaasgoyal abhaasgoyal requested review from a team and SeanBryan51 and removed request for a team August 17, 2025 23:11
@abhaasgoyal abhaasgoyal marked this pull request as ready for review August 17, 2025 23:11
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

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

Since Sean is away, I've started looking at the PR. I haven't reacquainted myself completely with benchcab so for the moment most of my comments are not much on the structure. I'll need more time for that to come.

if [ ! -z "${MODEL_OUTPUT_ID}" ] ; then
echo "Deleting existing files from model output ID"
$MEORG_BIN file delete_all $MODEL_OUTPUT_ID
echo "Updated model output ID"
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why we need this output here.

Copy link
Author

Choose a reason for hiding this comment

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

If a model output ID already exists with a given name, we want to preserve the model output ID (since in case we assume that the user is re-running the same experiment). However, we want to clean up any existing files, so that the experiment runs with the intended files of the user. (I have added a short comment on the same)

sleep $CACHE_DELAY

{% for exp_id in model_exp_ids %}
echo "Replace benchmarks to model output"
Copy link
Member

Choose a reason for hiding this comment

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

Using "Add benchmarks ..." in the output would make more sense to me than "Replace"

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the comment to "Add". The reason I chose "Replace" was, unlike adding experiments, if a benchmark already exists and we use meorg benchmark update, the existing benchmarks get overwritten (but yeah I don't see a use case for the user to not add benchmarks from scratch everytime in this workflow).

----------
config : dict
The configuration file with with/without optional keys
The configuration file with without optional keys
Copy link
Member

Choose a reason for hiding this comment

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

Neither "with without optional keys" nor "with/without optional keys" make any sense. Any idea what we are trying to say here?

Copy link
Author

Choose a reason for hiding this comment

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

I believe it's like the user may already have passed in the optional key (thus not replacing it), otherwise if the config file is without the necessary optional key, it would be replaced by a value calculated in read_optional_key.

"modules": ["intel-compiler/2021.1.1", "netcdf/4.7.4", "openmpi/4.1.0"],
"realisations": [
{"repo": {"svn": {"branch_path": "trunk"}}},
{"repo": {"svn": {"branch_path": "trunk"}}, "model_output_name": True},
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, this should return an error because just using the name "trunk" for the model output name should not be allowed.

Copy link
Author

Choose a reason for hiding this comment

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

I have added in the validation function for checking model output name derived from config file, along with tests.

Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

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

Second batch of comments. It tends to come bits by bits sorry.

I believe the benchcab's User Guide needs some modifications which are missing from this PR.

Comment on lines 184 to 192
mo_name = None
if r.get("name"):
mo_name = r["name"]
else:
repo = create_repo(
spec=r["repo"],
path=internal.SRC_DIR / (r["name"] if r.get("name") else Path()),
)
mo_name = Model(repo).name
Copy link
Member

Choose a reason for hiding this comment

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

I would revert to the previous implementation but using the name argument in create_repo()

Suggested change
mo_name = None
if r.get("name"):
mo_name = r["name"]
else:
repo = create_repo(
spec=r["repo"],
path=internal.SRC_DIR / (r["name"] if r.get("name") else Path()),
)
mo_name = Model(repo).name
mo_name = None
repo = create_repo(
spec=r["repo"],
path=internal.SRC_DIR / (r["name"] if r.get("name") else Path()),
name=r.get("name"),
)
mo_name = Model(repo).name

The implementation of Model().__init__() should assign to Model(repo).name:

  • the branch name if name is not present in the config
  • the value of name if it's present.

Copy link
Author

Choose a reason for hiding this comment

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

To resolve this, I am using r.get("name") both in Repo and Model initialisations since Model cannot determine the name just from Repo (unless it has a mandatory name parameter, which it doesn't for all the sub classes - for example LocalRepo has name but GitRepo doesn't)

            repo = create_repo(
                spec=r["repo"],
                path=internal.SRC_DIR / (r["name"] if r.get("name") else Path()),
            )
            mo_name = Model(repo, name=r.get("name")).name

For now, I'm not making it mandatory for Repo to have a name parameter (so usage of r.get("name") twice is fine.

return "Model output name does not start with number"

if len(name_keywords) == 1:
return "Model output name does not contain keyword after number"
Copy link
Member

Choose a reason for hiding this comment

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

I'm suggesting to change the error messages to be more direct, always using an affirmative sentence and importantly giving an example.

Suggested change
return "Model output name does not contain keyword after number"
return "Model output name must contain keywords after the initial number. E.g. 123-fixing-met-file-reading-error"

I also wonder if we want to build an error message that indicates all the mistakes in a given name at once, instead of returning on the first error encountered. Something like the following (incomplete and not formatted for the code):

msg=""
if len(name) == 0:
    msg+="Model output name can not be empty.\n"

if len(name) > 255:
    msg+="The length of model output name must be shorter than 255 characters.\n"

if msg:
    msg+="Example valid name: 123-fixing-met-file-reading-error"

return msg

Actually, the check on len(name)==0 indicates a problem with the code itself rather than the config I suspect so it might be weird to give a valid name example but I think it's a small inconvenience.

Copy link
Author

Choose a reason for hiding this comment

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

For the check on len(name)==0, I'm trying to treat the function as independent entity from the code (so if the code does have issues in the future, then it would be caught more easily). Let me know if this check is still not needed.

@ccarouge
Copy link
Member

ccarouge commented Sep 2, 2025

@abhaasgoyal I won't have much time to continue the review. I'll let @SeanBryan51 have a look. Sorry for switching reviewer all the time!

@SeanBryan51
Copy link
Collaborator

Hi @abhaasgoyal, as I understand these changes require CABLE-LSM/meorg_client#67. Can we merge that PR first and push a new meorg release so that in this PR we can update the minimum meorg version in meta.yaml and benchcab-dev.yaml?

@abhaasgoyal
Copy link
Author

@SeanBryan51, yes happy to get that merged in first before merging this

@SeanBryan51
Copy link
Collaborator

Hi @abhaasgoyal, now that CABLE-LSM/meorg_client#67 is merged and we have a new 0.5.0 release, please update the minimum meorg version in meta.yaml and benchcab-dev.yaml

@abhaasgoyal
Copy link
Author

abhaasgoyal commented Sep 24, 2025

About design decision recommendations for determining model output name:

  • Concatenation of realisations: On discussion, the workflow for most users is picking up specific branches as the name even if they have multiple realisations. They also want to minimise length of model output name for clarity. So the current methodology imposed seems to be the most suitable. It also does not restrict flexibility, since the user can edit the model output name via the name parameter as well.
  • TODO: A small part of hash [f(model_output_name, user, profile)], to go with model output name (upto 6 characters) at the end, with _ as the separator. For example - 123-my-branch_38j4ka

@SeanBryan51
Copy link
Collaborator

SeanBryan51 commented Sep 24, 2025

Hi @abhaasgoyal, thanks for the update.

In the meeting I suggested checking the issue number (inferred from meorg_output_name) actually pointed to a valid issue on GitHub. If this seems a bit overkill for the amount of effort necessary to achieve this, I'm happy to leave this as is and have this go in in a later PR.

Apologies for being pedantic about these things

@abhaasgoyal
Copy link
Author

I discussed with Gab about the hash structure for meorg_output_name. Some observations as follows:

  1. The information for the user is not currently available in benchcab (it's in a .json file accessible by meorg_client).
  2. It would be nice to have a unique hash related to all realisations, rather than just the one branch.

So for now, the proposed hash is f(realisation_names, profile). Regarding point 1, if we want to add the user in the hash as well, it can happen via importing the meorg_client package in benchcab. Is it okay to mix CLI calls and using internal package functions as well.

@SeanBryan51 I'll create an separate issue for validating meorg_output_name w.r.t. github issues

Copy link
Collaborator

@SeanBryan51 SeanBryan51 left a comment

Choose a reason for hiding this comment

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

Looks good! Just a small english rewording suggestion for the doc.

Co-authored-by: Sean Bryan <39685865+SeanBryan51@users.noreply.github.com>
@abhaasgoyal abhaasgoyal force-pushed the 331-model-output-endpoint-meorg branch from 6b3bc74 to 726d4e9 Compare October 15, 2025 00:36
@abhaasgoyal abhaasgoyal merged commit bf16e86 into main Oct 15, 2025
3 checks passed
@abhaasgoyal abhaasgoyal deleted the 331-model-output-endpoint-meorg branch October 15, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define benchcab workflow for model output

4 participants