(Closes #3461) duplicated script names - #3468
Conversation
|
I've fixed the unit test failures by slightly changing the test (instead of setting sys.path, I We do get additional failure in example, since without modifying sys.path, helper scripts in the same directory as the psyclone scripts are NOT found anymore (unless you set |
…orting helper scripts, but clean up sys.pathin the end.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3468 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 397 397
Lines 55577 55569 -8
=========================================
- Hits 55577 55569 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Failures in one example and nemo (lfric is fine) indicate that we should modify sys.path when importing and executing a script (so that helper scripts in the same directory as the script are found). That was done in ab86dd3, so once I've updated the documentation this should be ready to go. |
…ames do not need to be handled/removed anymore.
|
IT passed, ready for review. |
arporter
left a comment
There was a problem hiding this comment.
Thanks very much @hiker, this feels like a significant improvement. While reviewing it, I got very uncomfortable that our load_script routine (already) modifies global state and that this then has to be manually undone in multiple places after the script(s) have been used. I'm wondering whether there's a better way to do this that will prevent us making mistakes in the clean-up.
| @pytest.fixture(name="script_factory", scope="function") | ||
| def create_script_factor(tmpdir): | ||
| ''' Fixture that creates a psyclone optimisation script given the string | ||
| def script_factory(tmpdir, code: str) -> Path: |
There was a problem hiding this comment.
Since we're here, upgrade to tmp_path?
There was a problem hiding this comment.
All done, I've replaced all of os.path, and using pathlib everywhere now.
|
@arporter , I agree with the refactoring (including using a But if #1629 is being worked on, that would create huge conflicts, since this refactoring will need to introduce additional functions, i.e. moving code around quite a bit to avoid even deeper nesting. I see three options:
Can you let me know what you prefer? |
|
@hiker My PR won't be ready anytime soon, I found some blockers, but once completed it will simplify the generate.py. Andy and me discussed this and we decided you can keep the current implementation with the "del" statements, but add a new issue/TODOs, as we want to come back to clean this up at some point. |
|
Ready for next review, IT triggered (issue #3514 for cleanup refactoring added). |
|
Documentation failure is caused by the NEMO wiki now requiring an account. IT triggered |
| config_name = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
| "test_files", "dummy_config.cfg") | ||
|
|
||
| config_path = Path(get_base_path("lfric")) / ".." / "dummy_config.cfg" |
There was a problem hiding this comment.
Path(get_base_path("lfric")) is just LFRIC_BASE_PATH?
| @pytest.fixture(name="script_factory", scope="function") | ||
| def create_script_factor(tmpdir): | ||
| ''' Fixture that creates a psyclone optimisation script given the string | ||
| def script_factory(tmpdir, code: str) -> Path: |
Fixes #3461.