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

Add 'allow' and 'disallow' setting to each manager #1156

Merged
merged 2 commits into from
Oct 28, 2022

Conversation

shreekarSS
Copy link
Member

@shreekarSS shreekarSS commented Oct 11, 2022

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:

  • name: thoth-advise
    //Do not run this manager in the ps-nlp-tensorflow-gpu overlay
    env_disallow_list:
    • ps-nlp-tensorflow-gpu
      configuration:
      labels: [bot]
  • name: update
    //Run this manager in the ps-nlp-tensorflow-gpu overlay (only)
    env_allow_list:
    • ps-nlp-tensorflow-gpu
      configuration:
      labels: [bot]
  • name: info
    //No allow/disallow present: this manager applies to all runtimes
    ...

@sesheta sesheta added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 11, 2022
@sesheta sesheta added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 11, 2022
@shreekarSS shreekarSS changed the title [WIP] Add 'allow' and 'disallow' setting to each manager Add 'allow' and 'disallow' setting to each manager Oct 11, 2022
@sesheta sesheta removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 11, 2022
Copy link
Member

@KPostOffice KPostOffice left a 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)
Copy link
Member

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 -

Copy link
Member Author

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
Copy link
Member

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 &

Copy link
Member Author

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)
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

ack, thanks

@sesheta sesheta added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 12, 2022
@sesheta sesheta added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 12, 2022
Copy link
Member

@KPostOffice KPostOffice left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines 320 to 323
for mgr in managers:
if mgr.get("name") == "thoth-advise":
disallow_run_times = mgr.get("disallow", None)
allowed_run_times = mgr.get("allow", None)
Copy link
Member

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.

shreekarSS added a commit to shreekarSS/kebechet that referenced this pull request Oct 14, 2022
Signed-off-by: Shreekara <sshreeka@redhat.com>
@sesheta sesheta added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 14, 2022
@@ -172,11 +172,26 @@ def run(
return

managers = config.managers

if config.config.get("overlays_dir"):
runtime_environment = [
Copy link
Member

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

Copy link
Member

@KPostOffice KPostOffice left a 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

Comment on lines 718 to 750
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]
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 185 to 187
disallow_run_times = manager.get("disallow", None)
allowed_run_times = manager.get("allow", None)
Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack

shreekarSS added a commit to shreekarSS/kebechet that referenced this pull request Oct 17, 2022
Signed-off-by: Shreekara <sshreeka@redhat.com>
@shreekarSS shreekarSS force-pushed the diffrent_mgrs_overlay branch 2 times, most recently from 69f11a0 to e0fb342 Compare October 17, 2022 16:42
Copy link
Member

@KPostOffice KPostOffice left a 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:
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

ack done

Copy link
Member

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.

Copy link
Member

@harshad16 harshad16 left a 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.

@shreekarSS
Copy link
Member Author

Please update documentation for this feature in this PR itself.

Ack, thanks ,fixed

Copy link
Member

@harshad16 harshad16 left a 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.

docs/managers.rst Outdated Show resolved Hide resolved
Comment on lines 186 to 187
disallow_run_times = manager.get("disallow", None)
allowed_run_times = manager.get("allow", None)
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack, done

kebechet/kebechet_runners.py Show resolved Hide resolved
Copy link
Member

@harshad16 harshad16 left a 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.

@sesheta sesheta added the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2022
@sesheta sesheta removed the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2022
Copy link
Member

@KPostOffice KPostOffice left a 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

runtime_environments: List[str]
if runtime_environment:
runtime_environments = [runtime_environment]
if config.config.get("overlays_dir"):
Copy link
Member

Choose a reason for hiding this comment

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

elif here

managers:
- name: thoth-advise
# Do not run this manager in the ps-nlp-tensorflow-gpu overlay
disallow:
Copy link
Member

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?

Copy link
Member Author

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"
Copy link
Member

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?

Copy link
Member Author

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]
Copy link
Member

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 []

@shreekarSS shreekarSS force-pushed the diffrent_mgrs_overlay branch 2 times, most recently from 2339c93 to b771508 Compare October 25, 2022 15:52
@KPostOffice
Copy link
Member

/lgtm

@sesheta sesheta added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2022
Copy link
Member

@codificat codificat left a 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:
Copy link
Member

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 = [
Copy link
Member

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

ack,done

@sesheta sesheta removed the lgtm Indicates that a PR is ready to be merged. label Oct 27, 2022
@KPostOffice
Copy link
Member

/approve

@sesheta sesheta added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 27, 2022
Copy link
Member

@harshad16 harshad16 left a 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 👍

@sesheta sesheta added the lgtm Indicates that a PR is ready to be merged. label Oct 28, 2022
@sesheta
Copy link
Member

sesheta commented Oct 28, 2022

[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:
  • OWNERS [KPostOffice,harshad16]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[5pt] An option to configure different managers per overlay
5 participants