Skip to content

Enhancement: Improve Python Embedding to avoid requiring logic to be run upon import #3383

Description

@georgemccabe

The current implementation of Python Embedding is to import the user's script and then look for the required variables, e.g. met_data, to read data and attributes. This requires the logic to populate these variables to be run when the script is imported. This has been discovered to be problematic for scripts that use multiprocessing, as that logic should be executed when the script is executed, e.g. not called upon import but called when the script is run (__name__ == '__main__'). This paradigm also restricts how the scripts can be used for other purposes. For example, one cannot include useful functions that can imported into other scripts for use outside of Python Embedding if the logic is run when it is imported.

Describe the Enhancement

Review and enhance the existing logic so that it will work if the script is run instead of just imported. We will need to ensure backwards compatibility so that existing Python Embedding scripts still work.

Time Estimate

Estimate the amount of work required here.
Issues should represent approximately 1 to 3 days of work.

Sub-Issues

Consider breaking the enhancement down into sub-issues.

  • Add a checkbox for each sub-issue here.

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 a MET-X.Y.Z version, Consider for Next Release, or Backlog of Development Ideas
  • For a MET-X.Y.Z version, select the MET-X.Y Development project

Define Related Issue(s)

Consider the impact to the other METplus components.

Enhancement 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 develop.
    Branch name: feature_<Issue Number>_<Description>
  • Complete the development and test your changes.
  • Add/update log messages for easier debugging.
  • Add/update unit tests.
  • Add/update documentation.
  • Push local changes to GitHub.
  • Submit a pull request to merge into develop.
    Pull request: feature <Issue Number> <Description>
  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s) and Development issue
    Select: Milestone as the next official version
    Select: MET-X.Y Development project for development toward the next coordinated release
  • Iterate until the reviewer(s) accept and merge your changes.
  • Delete your fork or branch.
  • Close this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    🩺 Needs Triage

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions