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

Load dependencies from manifests. Fallback to current DEPENDENCIES. #22716

Closed
wants to merge 12 commits into from

Conversation

rohankapoorcom
Copy link
Member

@rohankapoorcom rohankapoorcom commented Apr 4, 2019

Description:

Load dependencies from manifests (if present). If not, fallback to the current approach of reading DEPENDENCIES from the module attribute.

Related issue (if applicable): relates to #22700

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@rohankapoorcom rohankapoorcom requested a review from a team as a code owner April 4, 2019 08:18
@homeassistant homeassistant added core small-pr PRs with less than 30 lines. cla-signed labels Apr 4, 2019
@ghost ghost assigned rohankapoorcom Apr 4, 2019
@ghost ghost added the in progress label Apr 4, 2019
@rohankapoorcom rohankapoorcom changed the title Load dependencies from manifests. Fallback to current DEPENDENCIES Load dependencies from manifests. Fallback to current DEPENDENCIES. Apr 4, 2019
@rohankapoorcom rohankapoorcom changed the title Load dependencies from manifests. Fallback to current DEPENDENCIES. Load dependencies from manifests. Fallback to current DEPENDENCIES. Apr 4, 2019
@balloob balloob mentioned this pull request Apr 4, 2019
13 tasks
homeassistant/setup.py Outdated Show resolved Hide resolved
homeassistant/setup.py Outdated Show resolved Hide resolved
@balloob
Copy link
Member

balloob commented Apr 5, 2019

Difficult to see MQTT tests because Circle doesn't make it past the static check.

homeassistant/setup.py Outdated Show resolved Hide resolved
@rohankapoorcom
Copy link
Member Author

Difficult to see MQTT tests because Circle doesn't make it past the static check.

Sorry about that. Didn't realize mypy was unhappy. We should make it past that part now.

@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

  1. You can check here to see all details of failed tests: https://circleci.com/build-insights/gh/home-assistant/home-assistant/load-dependencies-manifest

  2. Root [one of] cause is that the dependencies field in manifest.json are missing the DEPENDENCIES defined in the "platform" file.

For example, DEPENDENCIES in automation/__init__.py only has groups. However, automation/webhook.py depends on webhook component which have not been extracted to manifest.json

@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

Opened an arch issue to find the solution home-assistant/architecture#187

@ghost ghost assigned awarecan Apr 5, 2019
@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

There is another manifest issue. When we do the great migration, we create an empty __init__.py, in such case, the DEPENDENCIES still in the platform file, and not be extracted to manifest.json. I updated several cases broken the tests. I changed manifest.json those has only one platform.

@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

Now, I expected most test been fixed. automation.webhook will still fail due the manifest issue.

The majority issues I fixed in the tests are timing issue. Component and platform setup are separated tasks. async_setup_component finished doesn't mean platform is ready, we have to async_block_till_done() to make sure platform setup finished.

Those tests got passed before, but start failing after manifest change. My theory is their platform setup pretty quick in before, but became slow now as we have to do disk I/O to read manifest.json file.

@awarecan awarecan force-pushed the load-dependencies-manifest branch from 2043316 to ece8971 Compare April 5, 2019 16:36
@rohankapoorcom
Copy link
Member Author

Those tests got passed before, but start failing after manifest change. My theory is their platform setup pretty quick in before, but became slow now as we have to do disk I/O to read manifest.json file.

So we basically got lucky before? Had any of those platforms introduced anything that did I/O, we would have started seeing tests fail then too, right?

@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

We don't have so much disk I/O before, and most network I/O has been mocked in test. So there is another performance concern. We have 5000+ tests, that means at least 5000 more file I/O introduced in our tests. Let's see the result

@rohankapoorcom
Copy link
Member Author

What's the alternative? I don't think it's reasonable to mock out the manifest loads.

@awarecan
Copy link
Contributor

awarecan commented Apr 5, 2019

Still 50+ failures and they are new. It seems that previous test run didn't executed all tests at all.

@balloob
Copy link
Member

balloob commented Apr 5, 2019

Yeah, we should load them.

@rohankapoorcom rohankapoorcom requested a review from dgomes as a code owner April 5, 2019 20:38
@rohankapoorcom
Copy link
Member Author

I will continue on with this tonight. Thanks for moving it along @awarecan!

@rohankapoorcom
Copy link
Member Author

rohankapoorcom commented Apr 6, 2019

I managed to resolve another 10 failures. There's still one more that I haven't figured out: https://circleci.com/gh/home-assistant/home-assistant/5524#tests/containers/0

Annoyingly I'm unable to fail that one test on my local machine.

Help is always welcome :)

@rohankapoorcom
Copy link
Member Author

rohankapoorcom commented Apr 7, 2019

This is getting more interesting, I've been able to reproduce this test failure, but only when running the entire test suite. If I just run the module or the specific test it passes, making it particularly hard to debug. As far as I can tell, it seems like a test in a different class is causing this one to break.

I'm curious now, if it's possible to get the requirements loaded from the manifest first (without all of this test case difficulties). That way we could unblock #22717 and possibly merge that one first and then figure this out.

Okay, confirmed my theory, this single test is still broken when just requirements are read from the manifest, not only for dependencies. We'll need to get this test fixed before either can move forward.

@rohankapoorcom rohankapoorcom force-pushed the load-dependencies-manifest branch from fb39d00 to 88f58fe Compare April 7, 2019 19:12
@balloob
Copy link
Member

balloob commented Apr 9, 2019

The test fixes from this PR have been cherry-picked into dev. Please rebase.

@rohankapoorcom rohankapoorcom force-pushed the load-dependencies-manifest branch from 88f58fe to f915c39 Compare April 9, 2019 07:03
@rohankapoorcom
Copy link
Member Author

Rebased and pushed up.

@awarecan awarecan force-pushed the load-dependencies-manifest branch from f3e507d to 94fae3f Compare April 9, 2019 16:32
@awarecan awarecan mentioned this pull request Apr 9, 2019
3 tasks
@codecov
Copy link

codecov bot commented Apr 9, 2019

Codecov Report

Merging #22716 into dev will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #22716      +/-   ##
==========================================
- Coverage   93.85%   93.83%   -0.02%     
==========================================
  Files         449      449              
  Lines       36752    36756       +4     
==========================================
- Hits        34492    34490       -2     
- Misses       2260     2266       +6
Impacted Files Coverage Δ
setup.py 91.5% <0%> (-4.47%) ⬇️
homeassistant/components/emulated_roku/binding.py 92.64% <0%> (+1.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cac00f5...86851cf. Read the comment docs.

@balloob
Copy link
Member

balloob commented Apr 9, 2019

I have merged this PR into #22717

@balloob
Copy link
Member

balloob commented Apr 11, 2019

This was merged into #22717

@balloob balloob closed this Apr 11, 2019
@ghost ghost removed the in progress label Apr 11, 2019
@balloob balloob deleted the load-dependencies-manifest branch April 11, 2019 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed core small-pr PRs with less than 30 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants