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

Enable broadcasting with mismatched spaces. #80

Closed
wants to merge 1 commit into from

Conversation

jb-mackay
Copy link
Contributor

@jb-mackay jb-mackay commented Jul 6, 2022

Purpose and Content

Turns off broadcasting errors that stem from mismatched spaces using the tools from ClimaCore#640.

Benefits and Risks

This is necessary to couple components without using parent. Will allow #60 to be addressed. Current risks surround warning suppression - to prevent a warnings from being printed each broadcast, warnings and below are disabled in the logger. A more target approach would be more useful to only hide warnings stemming from broadcasting with mismatched spaces.

Linked Issues

PR Checklist

  • This PR has a corresponding issue OR is linked to an SDI.
  • I have followed CliMA's codebase contribution and style guidelines OR N/A.
  • I have followed CliMA's documentation policy.
  • I have checked all issues and PRs and I certify that this PR does not duplicate an open PR.
  • I linted my code on my local machine prior to submission OR N/A.
  • Unit tests are included OR N/A.
  • Code used in an integration test OR N/A.
  • All tests ran successfully on my local machine OR N/A.
  • All classes, modules, and function contain docstrings OR N/A.
  • Documentation has been added/updated OR N/A.

@jb-mackay jb-mackay self-assigned this Jul 6, 2022
Comment on lines +16 to +18
function __init__()
Logging.disable_logging(Logging.Warn) # disable warnings (for broadcasting with mismatched spaces)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@charleskawczynski @simonbyrne is there a better way to prevent these warnings from printing?

One option is to remove the warning all together if we think that the error should only be disabled when coupling anyways.

Another is perhaps to change the @warn to @debug so that they are at the lowest logging level and hidden by default.

Any suggestions?

@jb-mackay jb-mackay force-pushed the bm/climacore_broadcasting branch 2 times, most recently from 5610591 to b67df50 Compare July 8, 2022 18:27
Comment on lines +13 to +14
Fields.allow_mismatched_diagonalized_spaces() = true
Operators.allow_mismatched_fd_spaces() = true
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved into the test folder, it must be done at global scope.

Copy link
Member

Choose a reason for hiding this comment

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

The rest of the changes in this file can probably be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain your reasoning for both of these points? I was thinking we want to disable these errors anytime we are using the coupler. Maybe that is simply too broad? The benefit is that coupler users won't have to think about these levers.

Copy link
Member

Choose a reason for hiding this comment

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

This is kind of like type piracy. We should probably avoid changing other packages default behavior under the hood. What's the issue with doing this at the global level? I'm fairly certain it'll work, it's simple, and more transparent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense to me r.e. transparency. I just wanted to allow the user to not have to think about this when coupling and these errors are something we will want to disable pretty much every time we are coupling, therefore something more automatic seemed warranted.

Maybe a method that redefines these would be a happy medium? Something like

function allow_mismatched_spaces()
    @eval Fields.allow_mismatched_diagonalized_spaces() = true
    @eval Operators.allow_mismatched_fd_spaces() = true
end

I just feel that allow_mismatched_diagonalized_spaces and allow_mismatched_fd_spaces are pretty niche.

Copy link
Member

@charleskawczynski charleskawczynski Jul 8, 2022

Choose a reason for hiding this comment

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

I just wanted to allow the user to not have to think about this

This is not transparent.

I recommend not using @eval. My recommendation is to include this at the top level. That is by far the simplest way to handle this situation. We can hide it later if we want to make things pretty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I recommend not using @eval. My recommendation is to include this at the top level. That is by far the simplest way to handle this situation. We can hide it later if we want to make things pretty.

Ok, I'm fine with holding off then.

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.

Enable broadcasting with mismatched spaces
2 participants