Fix AttributeError: 'dict' object has no attribute 'lower' in compass setup#5
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
…ct API Agent-Logs-Url: https://github.com/alexolinhager/compass/sessions/244b692f-bbf9-47fa-98a7-090e833a1607 Co-authored-by: alexolinhager <131483939+alexolinhager@users.noreply.github.com>
Agent-Logs-Url: https://github.com/alexolinhager/compass/sessions/244b692f-bbf9-47fa-98a7-090e833a1607 Co-authored-by: alexolinhager <131483939+alexolinhager@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash in compass setup due to configparser issue
Fix Mar 31, 2026
AttributeError: 'dict' object has no attribute 'lower' in compass setup
Copilot AI
added a commit
that referenced
this pull request
Apr 1, 2026
Bug #1: config.get('restart_ensemble', {}) crashes because MpasConfigParser.get() expects (section, option) positional args, not a dict fallback. Fixed: config['restart_ensemble'] returns a SectionProxy with proper .get()/.getint()/.getfloat()/.getboolean() methods. Bug #2: _should_restart_run() looked for per-run analysis_results.json files that are never written. AnalysisStep writes analysis_summary.json to its own work dir containing an individual_results dict for all runs. Fixed: add analysis_summary_file config option; configure() loads the file and passes per-run dicts to _should_restart_run() via a new run_results param. RestartScheduler.create_config_file() now includes analysis_summary_file in generated configs. Bug #3: restart_attempt_N/ tracking dirs were never created by InPlaceRestartMember.setup(), so max_consecutive_restarts was effectively disabled and all attempt counters read 0. Fixed: setup() now creates restart_attempt_N/ dirs using a single os.listdir() call to find the highest existing attempt number. Bug #5: restart_scheduler.py docstring Examples section referenced a non-existent module path. Fixed to the correct path. Agent-Logs-Url: https://github.com/alexolinhager/compass/sessions/ca2d29bf-1246-415c-bf2c-9de7521fa55f Co-authored-by: alexolinhager <131483939+alexolinhager@users.noreply.github.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compass setupcrashed immediately becauseconfigure()calledconfig.get('restart_ensemble', {})— treatingMpasConfigParser(aconfigparser.ConfigParsersubclass) as a dict.configparser.get(section, option)interprets the second arg as the option name and calls.lower()on it, blowing up on a{}.Changes
test_case.py: Rewroteconfigure()to use the properconfigparserAPI throughout:config.get('restart_ensemble', 'spinup_work_dir')instead ofconfig.get('restart_ensemble', {}).get('spinup_work_dir')config.getint/getfloat/getboolean('restart_ensemble', option)withtry/except (configparser.NoSectionError, configparser.NoOptionError)for optional keys with defaultsimport configparserfor the specific exception typesChecklist
api.rst) has any new or modified class, method and/or functions listedE3SM-Projectsubmodule has been updated with relevant E3SM changesMALI-Devsubmodule has been updated with relevant MALI changesTestingin this PR) any testing that was used to verify the changesOriginal prompt
Bug
compass setupcrashes with:at
compass/landice/tests/ensemble_generator/sgh_restart_ensemble/test_case.py, line 60:Root Cause
configis anMpasConfigParser(frommpas_tools), which inherits fromconfigparser.ConfigParser. Its.get()signature isget(section, option)— notget(section, default)like a dict. Passing{}as the second argument causesconfigparserto call{}.lower(), which raisesAttributeError: 'dict' object has no attribute 'lower'.The code then goes on to use
sectionas if it were a config section proxy (section.get(...),section.getint(...),section.getboolean(...)), which is not howMpasConfigParser/configparserworks.Fix
In
compass/landice/tests/ensemble_generator/sgh_restart_ensemble/test_case.py, replace theconfigure()method body so that each config value is read directly viaconfig.get(section_name, option_name)(andconfig.getint,config.getfloat,config.getboolean) rather than through a fake section proxy.The corrected
configure()should look like:File to change
compass/landice/tests/ensemble_generator/sgh_restart_ensemble/test_case.pyon branchcopilot/replace-restart-member-classCurrent BlobSha:
16388c1dd0557165679ffb8e573a5c6f49678677All other files (
restart_member.py,__init__.py,restart_scheduler.py) do not need changes.The following is the prior conversation context from the user's chat exploration (may be truncated):
Assistant: The file content is truncated. Let me get the full files:
Assistant: I can see the current state. The commit
291d6794is on thesgh_ensemble_generator_templatebranch (the original, before the Copilot PR). Therestart_member.pythere still has the oldRestartMemberclass. Let me also look at what's on the Copilot PR branch now:Assistant: The files are being returned truncated. Let me look at the current state of the branch that has your
job_script.shsnippet to understand exactly what's there now:Assistant: Good — I now have enough context. Let me look at the current state of the base branch to understand exactly what's there now:
Assistant: Now I have a clear picture of the cu...
This pull request was created from Copilot chat.