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

Suite srv files mgr #3334

Merged
merged 18 commits into from
Oct 15, 2019
Merged

Suite srv files mgr #3334

merged 18 commits into from
Oct 15, 2019

Conversation

oliver-sanders
Copy link
Member

This is a small internal change with no associated Issue.

This came out of the import time investigations we were looking into the other day.

Something which has long bugged me it that we have to initialise the SuiteSrvFilesManager class every time we want to use it despite the fact that most of it's methods could be functions.

This PR:

  • Makes the suite_srv_files_mgr module purely functional.
  • Removes some unused code.
  • Tidies up and documents some constants.

Note I didn't use Python enum.Enum for the constants but just dumped them in classes (for namespaceing). The reason for this is that enums are a bit of a faff (you end up adding lots of MyEnum.Foo.value lines).

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Already covered by existing tests.
  • No change log entry required (internal only, invisible to users).
  • No documentation update required.

@oliver-sanders oliver-sanders self-assigned this Aug 29, 2019
@oliver-sanders oliver-sanders added this to the cylc-8.0.0 milestone Aug 29, 2019
@oliver-sanders
Copy link
Member Author

This will fail unit-tests.

Mock-based unit-tests are inherently fragile to implementation changes (which is annoying as that is when you need them the most). Two are still failing, I can't work out how to fix them without re-implementing them.

  • TestSuiteSrvFilesManager.test_register
  • TestScan.test_get_scan_items_from_fs_with_owner_active_only

I can't seem be able to patch imported functions the way it was done before e.g:

mocked_os.path.basename = os.path.basename

@kinow any advice on how to fix these tests?

@kinow
Copy link
Member

kinow commented Aug 29, 2019

Created a PR in case that's easier to copy/adapt the code from: oliver-sanders#10

@oliver-sanders
Copy link
Member Author

not able to mock os by itself normally. So the only way is to be specific about what needs to be mocked.

Aah, OK, I've no idea why this change would break that.

Created a PR in case that's easier to copy/adapt the code from: oliver-sanders#10

Thanks, would have taken me forever to work that out.

@cylc cylc deleted a comment Aug 30, 2019
@oliver-sanders
Copy link
Member Author

oliver-sanders commented Aug 30, 2019

Looks like there might be a small speed-up, I've measured an improvement of ~10% in my slow, bloated Conda environment.

$ git checkout master
$ cylc run generic --hold
$ prof --n=10 --shell=python 'from cylc.flow.network.client import SuiteRuntimeClient; SuiteRuntimeClient("generic")'
1.91900000000000000000
$ git checkout suite-srv-files-mgr
$ prof --n=10 --shell=python 'from cylc.flow.network.client import SuiteRuntimeClient; SuiteRuntimeClient("generic")'
1.69400000000000000000

@oliver-sanders
Copy link
Member Author

Deconflicted.

@cylc cylc deleted a comment Sep 3, 2019
@oliver-sanders
Copy link
Member Author

Merged in latest master with TB tweaks.

@cylc cylc deleted a comment Sep 9, 2019
Copy link
Contributor

@matthewrmshin matthewrmshin left a comment

Choose a reason for hiding this comment

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

Quick comment.

cylc/flow/suite_srv_files_mgr.py Outdated Show resolved Hide resolved
@oliver-sanders oliver-sanders modified the milestones: cylc-8.0.0, cylc-8.0a2 Sep 19, 2019
@cylc cylc deleted a comment Oct 7, 2019
@cylc cylc deleted a comment Oct 7, 2019
Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

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

Approving as @oliver-sanders has addressed some comments and argued his way out of the others 👍

@hjoliver hjoliver requested review from matthewrmshin and removed request for matthewrmshin October 8, 2019 23:41
bin/cylc-edit Outdated Show resolved Hide resolved
@cylc cylc deleted a comment Oct 10, 2019
Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Added some comments, but I think these are no blockers @oliver-sanders . Feel free to press the merge button if OK (I guess we can more renaming class name and adding docstrings to another follow-up PR or issue?)

cylc/flow/tests/test_suite_files.py Outdated Show resolved Hide resolved
cylc/flow/suite_files.py Outdated Show resolved Hide resolved
cylc/flow/suite_files.py Show resolved Hide resolved
cylc/flow/suite_files.py Show resolved Hide resolved
@kinow
Copy link
Member

kinow commented Oct 10, 2019

And code looking much cleaner 👏 👏 👏

@oliver-sanders
Copy link
Member Author

Addressed comments, waiting for tests to pass...

@cylc cylc deleted a comment Oct 10, 2019
@oliver-sanders
Copy link
Member Author

Deconflicted.

@oliver-sanders
Copy link
Member Author

(coverage is actually up slightly but the patch coverage is low because suite_srv_files_mgr coverage was low before)

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

One unused import, but not a blocker. Re-approved 👍

cylc/flow/tests/test_suite_files.py Show resolved Hide resolved
@cylc cylc deleted a comment Oct 15, 2019
@hjoliver hjoliver merged commit 972baf1 into cylc:master Oct 15, 2019
@oliver-sanders oliver-sanders deleted the suite-srv-files-mgr branch May 27, 2020 11:28
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.

4 participants