-
Notifications
You must be signed in to change notification settings - Fork 103
profiles: improve SUPPORTED_DEVICES handling and profile identification #1533
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
Open
map-b
wants to merge
3
commits into
openwrt:main
Choose a base branch
from
map-b:improve-supported-devices-handling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,11 @@ def valid_profile(profile: str, build_request: BuildRequest) -> bool: | |
| profiles = app.profiles[build_request.version][build_request.target] | ||
| if profile in profiles: | ||
| return True | ||
| else: | ||
| for supported_devices in profiles.values(): | ||
| if profile in supported_devices: | ||
| return True | ||
|
|
||
| if len(profiles) == 1 and "generic" in profiles: | ||
| # Handles the x86, armsr and other generic variants. | ||
| build_request.profile = "generic" | ||
|
|
@@ -135,9 +140,38 @@ def valid_profile(profile: str, build_request: BuildRequest) -> bool: | |
| "forums for more information." | ||
| ) | ||
|
|
||
| build_request.profile = app.profiles[build_request.version][build_request.target][ | ||
| build_request.profile | ||
| ] | ||
| # Translate DTS compatible strings to actual profile names: | ||
| # *Only firmware-selector client is suppose to send the profile directly, | ||
| # *translate if it is not an already translated profile | ||
| if build_request.profile not in app.profiles[build_request.version][build_request.target]: | ||
| first_occurrence = 0 | ||
| profiles_appearances: dict[str, int] = dict() | ||
| for profile, supported_devices in app.profiles[build_request.version][build_request.target].items(): | ||
| if build_request.profile in supported_devices: | ||
| profiles_appearances[profile] = supported_devices.index(build_request.profile) | ||
|
|
||
| if len(profiles_appearances) == 1: | ||
| build_request.profile = profiles_appearances[0] | ||
| else: | ||
| # If there are multiple profiles including the requested DTS compatible string, | ||
| # select the one where it is the first in the list of SUPPORTED_DEVICES | ||
| logging.info( | ||
| f"DTS Compatible string: {build_request.profile} appears in " | ||
| f"multiple profiles, included in: {profiles_appearances}" | ||
| ) | ||
| for profile, index in profiles_appearances.items(): | ||
| if index == 0: | ||
| first_occurrence += 1 | ||
| build_request.profile = profile | ||
| if first_occurrence != 1: | ||
| return validation_failure( | ||
| f"Identification profile problem: {build_request.profile}. " | ||
| "The requested DTS compatible string has more than one " | ||
| "profile including it as the first SUPPORTED_DEVICES. " | ||
| "Or it is not the first in the list for any profile. " | ||
| f"{profiles_appearances} Please check the forums for more information." | ||
| ) | ||
|
|
||
| return ({}, None) | ||
|
|
||
|
|
||
|
|
@@ -209,9 +243,6 @@ def api_v1_build_post( | |
| request: Request, | ||
| user_agent: str = Header(None), | ||
| ): | ||
| # Sanitize the profile in case the client did not (bug in older LuCI app). | ||
| build_request.profile = build_request.profile.replace(",", "_") | ||
|
|
||
| add_build_event("requests") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This revert d7fd828 made this, I am not sure why. You are right on that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
|
||
| request_hash: str = get_request_hash(build_request) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (len(profiles) == 1 or "geos" in profiles) and "generic" in profiles:To remark that "geos" case is an exception in the "generic" targets/platforms? Adding a comment too?
@efahl I can add a separate commit for that issue since this PR is "touching" this code