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

Bugfix: Fix final log output missing when instance IDs are used in process list #2830

Closed
24 tasks
georgemccabe opened this issue Dec 13, 2024 · 1 comment · Fixed by #2840 or #2841
Closed
24 tasks
Assignees
Labels
alert: NEED ACCOUNT KEY Need to assign an account key to this issue type: bug Fix something that is not working
Milestone

Comments

@georgemccabe
Copy link
Collaborator

Describe the Problem

Currently there is a bug when instance names in the process list are used where the final logs like "INFO: METplus has successfully finished running." and the path to the log file are not shown.

Expected Behavior

All log output, including final log info reporting success of overall METplus run and path to the log file, are shown, even when using instance identifiers in the process list.

Environment

Describe your runtime environment:
Any

To Reproduce

Describe the steps to reproduce the behavior:
1. Copy parm/use_cases/met_tool_wrapper/GridStat/GridStat.conf to another directory
2. Modify conf file to replace PROCESS_LIST line:

from:

PROCESS_LIST = GridStat

to:

PROCESS_LIST = GridStat(inst1), GridStat(inst2)

[inst1]

LEAD_SEQ = 12

[inst2]

LEAD_SEQ = 12

[config]

3. Run use case and confirm that final log output is not shown. Last log line will be success status of grid_stat run

Relevant Deadlines

List relevant project deadlines here or state NONE.

Funding Source

Define the source of funding and account keys here or state NONE.

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required
  • Select scientist(s) or no scientist required

Labels

  • Review default alert labels
  • Select component(s)
  • Select priority
  • Select requestor(s)

Milestone and Projects

  • Select Milestone as the next bugfix version
  • Select Coordinated METplus-X.Y Support project for support of the current coordinated release
  • Select METplus-Wrappers-X.Y.Z Development project for development toward the next official release

Define Related Issue(s)

Consider the impact to the other METplus components.

Bugfix Checklist

See the METplus Workflow for details.

  • Complete the issue definition above, including the Time Estimate and Funding Source.

  • Fork this repository or create a branch of main_<Version>.
    Branch name: bugfix_<Issue Number>_main_<Version>_<Description>

  • Fix the bug and test your changes.

  • Add/update log messages for easier debugging.

  • Add/update unit tests.

  • Add/update documentation.

  • Add any new Python packages to the METplus Components Python Requirements table.

  • Push local changes to GitHub.

  • Submit a pull request to merge into main_<Version>.
    Pull request: bugfix <Issue Number> main_<Version> <Description>

  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s) and Development issue
    Select: Milestone as the next bugfix version
    Select: Coordinated METplus-X.Y Support project for support of the current coordinated release

  • Iterate until the reviewer(s) accept and merge your changes.

  • Delete your fork or branch.

  • Complete the steps above to fix the bug on the develop branch.
    Branch name: bugfix_<Issue Number>_develop_<Description>
    Pull request: bugfix <Issue Number> develop <Description>
    Select: Reviewer(s) and Development issue
    Select: Milestone as the next official version
    Select: METplus-Wrappers-X.Y.Z Development project for development toward the next official release

  • Close this issue.

@georgemccabe georgemccabe added type: bug Fix something that is not working alert: NEED MORE DEFINITION Not yet actionable, additional definition required alert: NEED ACCOUNT KEY Need to assign an account key to this issue alert: NEED CYCLE ASSIGNMENT Need to assign to a release development cycle labels Dec 13, 2024
@georgemccabe georgemccabe added this to the METplus-6.1.0 milestone Dec 13, 2024
@georgemccabe georgemccabe self-assigned this Dec 13, 2024
@github-project-automation github-project-automation bot moved this to 🩺 Needs Triage in METplus-6.1.0 Development Dec 13, 2024
@georgemccabe georgemccabe moved this from 🩺 Needs Triage to 🎯 Up Next in METplus-6.1.0 Development Dec 13, 2024
@georgemccabe georgemccabe moved this from 🩺 Needs Triage to 🎯 Up Next in METplus-Wrappers-6.0.0 Development Dec 13, 2024
@georgemccabe georgemccabe removed alert: NEED CYCLE ASSIGNMENT Need to assign to a release development cycle alert: NEED MORE DEFINITION Not yet actionable, additional definition required labels Dec 13, 2024
georgemccabe added a commit that referenced this issue Dec 17, 2024
…t are created for copying values for process list instances so they are not closed before the end of the run.
georgemccabe added a commit that referenced this issue Dec 17, 2024
…t are created for copying values for process list instances so they are not closed before the end of the run.
@georgemccabe georgemccabe moved this from 🎯 Up Next to 🔎 In review in METplus-Wrappers-6.0.0 Development Dec 18, 2024
@georgemccabe georgemccabe moved this from 🎯 Up Next to 🔎 In review in METplus-6.1.0 Development Dec 18, 2024
@georgemccabe
Copy link
Collaborator Author

Some notes about what I determined was happening and how it was fixed:

The config_metplus.setup function creates a METplusConfig object from the command line arguments. It also sets up the logger with handlers for terminal and file output. This logger is stored in the METplusConfig object. Issue #2245 was created because multiple runs of METplus started concurrently (and the pytests configs objects) were writing all of their logs to the same files redundantly. This was resolved by writing a __del__ function for METplusConfig to close the logger handlers when the object goes out of scope and is deleted. The METplusConfig object created by config_metplus.setup is passed to the run_util.run_metplus function to initialize the wrapper classes and persists after the wrappers are run to be passed to the run_util.post_run_cleanup function to output the final logs of the run (e.g. success/failure of METplus and log file path).

To handle Instance Names in the Process List, a new METplusConfig object is created and populated with the values from the [config] section and values from the [instance_name] section. This instance of the config object uses the same logger as the original. The issue arises when the run_util.run_metplus function ends and the CommandBuilder (METplus wrapper base class) instances go out of scope and are deleted. This closes the logger handlers before the run_util.post_run_cleanup function is called.

To handle this, I modified the METplusConfig class to track if it is the original instance or a "copy" instance used for handling instance IDs. If it is a "copy," then it does not remove the logger handlers, assuming that the original copy will do this at the end of the METplus run when it goes out of scope.

There may be a better way to handle this, such as decoupling the logger and the METplusConfig object so that the config does not clean up the logger to prevent the logger's scope to be determined by the config object's scope.

georgemccabe added a commit that referenced this issue Dec 18, 2024
* Per #2830, skip closing of log handlers for METplusConfig objects that are created for copying values for process list instances so they are not closed before the end of the run.

* remove some output directories after tests are run
@github-project-automation github-project-automation bot moved this from 🔎 In review to 🏁 Done in METplus-6.1.0 Development Dec 18, 2024
@github-project-automation github-project-automation bot moved this from 🔎 In review to 🏁 Done in METplus-Wrappers-6.0.0 Development Dec 18, 2024
@georgemccabe georgemccabe changed the title Bugfix: Final log output missing when instance IDs are used in process list Bugfix: Fix final log output missing when instance IDs are used in process list Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert: NEED ACCOUNT KEY Need to assign an account key to this issue type: bug Fix something that is not working
Projects
Status: 🏁 Done
Status: 🏁 Done
1 participant