Skip to content

Only raise integrationnotfound for dependencies#48241

Merged
balloob merged 8 commits intohome-assistant:devfrom
alandtse:after_dependencies
Apr 1, 2021
Merged

Only raise integrationnotfound for dependencies#48241
balloob merged 8 commits intohome-assistant:devfrom
alandtse:after_dependencies

Conversation

@alandtse
Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

Change the behavior of integrationnotfound to only raise for dependencies and not after_dependencies.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Comment thread homeassistant/requirements.py Outdated
@alandtse alandtse requested a review from bdraco March 25, 2021 04:46
Comment thread tests/test_requirements.py Outdated
@alandtse alandtse requested a review from bdraco March 30, 2021 04:11
Comment thread homeassistant/requirements.py Outdated
Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

One small suggestion above

@alandtse alandtse requested a review from bdraco March 30, 2021 06:03
Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@alandtse alandtse force-pushed the after_dependencies branch from c10b648 to 8d22b03 Compare March 30, 2021 06:56
@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 30, 2021

Should we only allow this behavior on custom integrations?

As for our core integrations, should not depend on external or non-existing ones (no matter if after or not).

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 30, 2021

I agree. We should only accept this behavior for custom components 👍

Copy link
Copy Markdown
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Please make this only apply to non-core integrations per the discussion above

@alandtse
Copy link
Copy Markdown
Contributor Author

Then shouldn't we block after dependencies for core components since it's the exact same as dependencies? The only distinction was the optionality.

@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 30, 2021

Then shouldn't we block after dependencies for core components since it's the exact same as dependencies? The only distinction was the optionality.

The difference is the allowing to silently fail on non-existing after dependencies (non-existing integrations). In your linked issue, hacs is an after dependency. A user doesn't have to have that. For a custom integration, that is fine. However, we don't want to have loose dependencies in our core integration. If a core integration has an after dependency to hacs and a user doesn't have it... it should fail (just like before this PR).

@alandtse
Copy link
Copy Markdown
Contributor Author

alandtse commented Mar 30, 2021

But that's not what the described behavior in the documentation is. If core treats both dependencies the same, it's not a useful field for core integrations to have after dependencies because it's not optional. They will fail if the after dependency is missing.

In theory a core integration could enable extra functionality if a custom component was available. That's what the field apparently was supposed to allow. If the core component should fail if that optional dependency is missing, the field should be removed for core.

@alandtse
Copy link
Copy Markdown
Contributor Author

alandtse commented Mar 30, 2021

Specifically:

This option is used to specify dependencies that might be used by the integration but aren't essential. . . . For example, if the camera integration might use the stream integration in certain configurations, adding stream to after_dependencies of camera's manifest, will ensure that stream is loaded before camera if it is configured. If stream is not configured, camera will still load.

https://developers.home-assistant.io/docs/creating_integration_manifest/#after-dependencies

If after_dependencies should not have this behavior for core, it should be explicitly mentioned as not allowed by core. Otherwise, it behaves identically to dependencies and is a redundant option that isn't obvious to a developer. Personally, I think it should allow after_dependencies because it's possible that a core integration could leverage a custom integration. I don't think custom integrations should be treated as second class but that's another discussion.

@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 31, 2021

Yes, this requires a change to the developer documentation as well. Nevertheless, it should be implemented as suggested above.

because it's possible that a core integration could leverage a custom integration

No, we should not allow that, that was the whole point of the review.

@alandtse
Copy link
Copy Markdown
Contributor Author

Yes, but why are we offering two options that behave identically for core components? Shouldn't after_dependencies be marked as not allowed for core?

Again, I'm not arguing against implementation, I'm arguing that the existence of two identical options in manifest.json is confusing. I haven't heard a response on that point.

@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 31, 2021

Yes, but why are we offering two options that behave identically for core components? Shouldn't after_dependencies be marked as not allowed for core?

Nope, for example, an integration can use cloud webhooks, but if a user doesn't have the cloud integration, then that is fine too. So within the core, this is actually used and needed.

alandtse added a commit to alandtse/developers.home-assistant that referenced this pull request Apr 1, 2021
@alandtse alandtse requested a review from bdraco April 1, 2021 03:51
@alandtse
Copy link
Copy Markdown
Contributor Author

alandtse commented Apr 1, 2021

Change implemented and clarification to docs submitted.

Comment thread homeassistant/requirements.py Outdated
@bdraco
Copy link
Copy Markdown
Member

bdraco commented Apr 1, 2021

Lgtm once the pylint is fixed

Comment thread homeassistant/requirements.py Outdated
@balloob balloob merged commit 125161d into home-assistant:dev Apr 1, 2021
frenck pushed a commit to home-assistant/developers.home-assistant that referenced this pull request Apr 1, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing after_dependencies should not raise exception if dependency is missing

5 participants