-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add 'allow' and 'disallow' setting to each manager #1156
Add 'allow' and 'disallow' setting to each manager #1156
Conversation
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.
Good start!
I think it might make sense to make managerbase take runtime_environments as a list and have it calculated this way.
See here
allowed_run_times = managers[0].get("allow", None) | ||
if disallow_run_times: | ||
runtime_environments = list( | ||
set(runtime_environments) ^ set(disallow_run_times) |
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.
I think this should just be set subtraction -
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.
ack, done
set(runtime_environments) ^ set(disallow_run_times) | ||
) | ||
if allowed_run_times: | ||
runtime_environments = allowed_run_times |
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.
I think this would be better as set intersection &
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.
ack, done
@@ -316,6 +316,15 @@ def run(self, labels: list, analysis_id=None): | |||
runtime_environments = [ | |||
e["name"] for e in thoth_config["runtime_environments"] | |||
] | |||
managers = thoth_config.get("managers") | |||
disallow_run_times = managers[0].get("disallow", None) |
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.
This should be per manager, not global to all managers
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.
ack, thanks
8b9d789
to
77d466e
Compare
77d466e
to
5dd79b2
Compare
5dd79b2
to
651f148
Compare
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.
kebechet/kebechet/kebechet_runners.py
Line 208 in 356af8e
if manager_configuration.pop("enabled", True): |
Let's try getting a list of runtime environments here and passing it directly to the manager. Replacing the current parameter runtime_environment
with runtime_environments
that takes a list. This should help with code duplication. It will require a bit more reworking though.
for mgr in managers: | ||
if mgr.get("name") == "thoth-advise": | ||
disallow_run_times = mgr.get("disallow", None) | ||
allowed_run_times = mgr.get("allow", None) |
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.
This shouldn't have to be done here, should be passed through the managers configuration variables.
Signed-off-by: Shreekara <sshreeka@redhat.com>
kebechet/kebechet_runners.py
Outdated
@@ -172,11 +172,26 @@ def run( | |||
return | |||
|
|||
managers = config.managers | |||
|
|||
if config.config.get("overlays_dir"): | |||
runtime_environment = [ |
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.
Let's change the name to runtime_environments
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.
Looks good. A few comments
kebechet/managers/update/update.py
Outdated
if self.runtime_environment not in runtime_environment_names: | ||
# This is not a warning as it is expected when users remove and change runtime_environments | ||
_LOGGER.info("Requested runtime does not exist in target repo.") | ||
return None | ||
runtime_environments = [self.runtime_environment] |
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.
We should move this check down into the for loop and just replace return None
with continue
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.
fixed
kebechet/kebechet_runners.py
Outdated
disallow_run_times = manager.get("disallow", None) | ||
allowed_run_times = manager.get("allow", None) |
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.
These are technically mutually exclusive. Not sure how important it is to users though.
@@ -172,11 +172,26 @@ def run( | |||
return | |||
|
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.
We need to respect the passed runtime_environment. We could also allow the user to pass a list of runtime_environments in the future, I don't think we need to do this now though.
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.
ack
Signed-off-by: Shreekara <sshreeka@redhat.com>
69f11a0
to
e0fb342
Compare
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.
One comment in two spots, otherwise it looks good!
|
||
If this project does not use requirements.txt or Pipfile then remove thoth-advise | ||
manager from your .thoth.yaml configuration.""" | ||
if self.runtime_environments: |
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.
This check shouldn't be necessary if the default would be an empty list. If the default is None
however, you could change the for loop to:
for e in self.runtime_environments or []:
Here and in update manager
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.
ack done
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.
I still see the if
statement in the current PR. I think it can be handled in the for
as @KPostOffice mention.
e0fb342
to
eed0a55
Compare
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.
Please update documentation for this feature in this PR itself.
Ack, thanks ,fixed |
0bb87a8
to
c54451a
Compare
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.
thanks for the great work.
dropped a few comments.
kebechet/kebechet_runners.py
Outdated
disallow_run_times = manager.get("disallow", None) | ||
allowed_run_times = manager.get("allow", None) |
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.
for default: empty list []
might be better than None
.
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.
ack, done
c54451a
to
c9de68e
Compare
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.
Thanks
/lgtm
PTAL @KPostOffice when you get some time.
c9de68e
to
a099ae5
Compare
a099ae5
to
698eb65
Compare
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.
A few more comments
kebechet/kebechet_runners.py
Outdated
runtime_environments: List[str] | ||
if runtime_environment: | ||
runtime_environments = [runtime_environment] | ||
if config.config.get("overlays_dir"): |
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.
elif here
docs/managers.rst
Outdated
managers: | ||
- name: thoth-advise | ||
# Do not run this manager in the ps-nlp-tensorflow-gpu overlay | ||
disallow: |
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.
I'm thinking we should make the name more clear. What do you think about env_allow_list
and env_disallow_list
?
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.
ack, will work on that
@@ -109,6 +109,7 @@ def __init__(self, *args, **kwargs): | |||
# We do API calls once for merge requests and we cache them for later use. | |||
self._cached_merge_requests = None | |||
self._pr_list = [] | |||
self.runtime_environment = "default" |
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.
Why is this line added here?
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.
previously , self.runtime_environment was a string, being used in https://github.com/thoth-station/kebechet/blob/master/kebechet/managers/update/update.py#L761 and many more places.
Since we are converting it list of strings, do not want to break the code since it's already being used in various methods, created a variable to keep it running
elif runtime_environment_names: | ||
runtime_environments = [runtime_environment_names[0]] | ||
else: | ||
runtime_environments = [None] |
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.
I think we lost the "default" functionality here. I think the for loop should probably be default [None]
instead of []
2339c93
to
b771508
Compare
/lgtm |
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.
Found one minor thing remaining
|
||
If this project does not use requirements.txt or Pipfile then remove thoth-advise | ||
manager from your .thoth.yaml configuration.""" | ||
if self.runtime_environments: |
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.
I still see the if
statement in the current PR. I think it can be handled in the for
as @KPostOffice mention.
@@ -311,51 +311,43 @@ def run(self, labels: list, analysis_id=None): | |||
|
|||
with open(".thoth.yaml", "r") as f: | |||
thoth_config = yaml.safe_load(f) | |||
|
|||
if thoth_config.get("overlays_dir"): | |||
runtime_environments = [ |
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.
As we are removing the local runtime_environments
var, let's also remove its declaration above (line 297)
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.
ack,done
Signed-off-by: Shreekara <sshreeka@redhat.com>
Signed-off-by: Shreekara <sshreeka@redhat.com>
b771508
to
16c8374
Compare
/approve |
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.
/lgtm
lets get this in 👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: harshad16, KPostOffice The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Shreekara sshreeka@redhat.com
Related Issues and Dependencies
Fixes: #1126
…
This Pull Request implements
New config setting for managers in .thoth.yaml
For ex:
managers:
//Do not run this manager in the ps-nlp-tensorflow-gpu overlay
env_disallow_list:
configuration:
labels: [bot]
//Run this manager in the ps-nlp-tensorflow-gpu overlay (only)
env_allow_list:
configuration:
labels: [bot]
//No allow/disallow present: this manager applies to all runtimes
...