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

Poem 047 Implementation 1 #2005

Merged
merged 13 commits into from
Apr 20, 2021
Merged

Poem 047 Implementation 1 #2005

merged 13 commits into from
Apr 20, 2021

Conversation

andrewellis55
Copy link
Contributor

Summary

Implementation 1 from POEM 047. Enables components to access their inputs and outputs without dependency on the problem metadata

Related Issues

  • Resolves #PEOM 047

Backwards incompatibilities

None

New Dependencies

None


if __name__ == '__main__':

p = Parabola()
Copy link
Member

Choose a reason for hiding this comment

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

Can you refactor this as a test using a unittest.TestCase? That's how we do our testing in OpenMDAO. See any of our other test_* files for examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test Refactor should now be complete. I left it in the root folder as I'm not sure when you want to stash it (or even if it's a test you'd want to keep around).

Copy link
Contributor

@swryan swryan Apr 16, 2021

Choose a reason for hiding this comment

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

since the code being tested is in openmdao/core/system.py, we would want this test in openmdao/core/tests/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just moved it there and renamed to match what it's testing (rather than just referencing the POEM number)

andrewellis55 added 2 commits April 16, 2021 11:25
Addressed swryans comment
Test Code refactor as per Bret
if self._problem_meta['model_ref']() is not None:
model_ref = self._problem_meta['model_ref']()
else:
model_ref = None
Copy link
Contributor

Choose a reason for hiding this comment

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

the if/else here is unnecessary?
this is equivalent to model_ref = self._problem_meta['model_ref']()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, yep, good point. Should be corrected now

Copy link
Contributor

@swryan swryan Apr 16, 2021

Choose a reason for hiding this comment

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

actually, I think I see what you intended to do here... did you mean this?

        if self._problem_meta is not None:
            model_ref = self._problem_meta['model_ref']()
        else:
            model_ref = None

since the following statement expects model_ref to exist even if _problem_meta is None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I think I jumped to changing things without thinking about what I was doing. Yes, what you've written above is correct and should have the behavior I intended. I've updated the latest commit accordingly.

andrewellis55 added 4 commits April 16, 2021 11:49
Removed unnecessary if
Removed file from root level
Updated to ensure model_ref is assigned
@swryan
Copy link
Contributor

swryan commented Apr 16, 2021

Thanks for your effort on this @andrewellis55 ... you can ignore the GitHub (OpenMDAO Test) failures, since we are having some issues with those right now, however it does look like there are a couple of PEP style violations that are getting flagged by openmdao/code_review/test_lint_peps.py

openmdao/code_review/test_lint_peps.py:LintTestCase.test_pep257 ... FAIL (00:00:3.69, 610 MB)
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/testflo/test.py", line 425, in _try_call
    func()
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/code_review/test_lint_peps.py", line 121, in test_pep257
    self.fail('{} PEP 257 Failure(s):\n'.format(len(failures)) + '\n'.join(failures))
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/unittest/case.py", line 693, in fail
    raise self.failureException(msg)
AssertionError: 1 PEP 257 Failure(s):
/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/core/system.py:4832 in private method `_get_var_meta`:
        D202: No blank lines allowed after function docstring (found 1)
/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/code_review/test_lint_peps.py:LintTestCase.test_pep8 ... FAIL (00:00:5.56, 610 MB)
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/testflo/test.py", line 425, in _try_call
    func()
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/code_review/test_lint_peps.py", line 115, in test_pep8
    self.fail('{} PEP 8 Failure(s):\n'.format(report.total_errors) + '\n'.join(failures))
  File "/home/travis/miniconda/envs/PY3/lib/python3.7/unittest/case.py", line 693, in fail
    raise self.failureException(msg)
AssertionError: 3 PEP 8 Failure(s):
/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/core/system.py:4848: [W293] blank line contains whitespace
^
/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/core/system.py:4853: [E303] too many blank lines (2)
        if model_ref is not None:
        ^
/home/travis/miniconda/envs/PY3/lib/python3.7/site-packages/openmdao/core/system.py:5137: [W391] blank line at end of file

Thanks again for your contribution...

andrewellis55 added 5 commits April 16, 2021 13:39
@andrewellis55
Copy link
Contributor Author

@swryan Thanks for you help reviewing the changes. The PEP issues should be fixed with the latest commit

@swryan swryan merged commit 40a7d9c into OpenMDAO:master Apr 20, 2021
@swryan swryan added the POEM Indicates an issue/PR that references a POEM label Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
POEM Indicates an issue/PR that references a POEM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants