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

feat(oracle): add kwargs to utility functions #332

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

mjdonis
Copy link
Contributor

@mjdonis mjdonis commented Jan 4, 2024

No description provided.

@mjdonis mjdonis force-pushed the oracle-util-kwargs branch 2 times, most recently from 596e030 to 7690c90 Compare January 5, 2024 10:18
Copy link
Collaborator

@aciba90 aciba90 left a comment

Choose a reason for hiding this comment

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

Apart from the version number, LGTM, thanks!

VERSION Outdated
@@ -1 +1 @@
1!5.12.1
1!5.13.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should reset the patch version to 0.

Suggested change
1!5.13.1
1!5.13.0

@mjdonis mjdonis force-pushed the oracle-util-kwargs branch from 7690c90 to 23b2329 Compare January 12, 2024 11:36
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but I do have one inline comment/question.

@@ -13,7 +15,9 @@
log = logging.getLogger(__name__)


def wait_till_ready(func, current_data, desired_state, sleep_seconds=1000):
def wait_till_ready(
func, current_data, desired_state, sleep_seconds=1000, **kwargs
Copy link
Member

@TheRealFalcon TheRealFalcon Jan 12, 2024

Choose a reason for hiding this comment

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

I think this could lead to some somewhat weird call semantics. For example, with a call like

wait_till_ready(
            func=self.compute_client.get_instance,
            current_data=self.instance_data,
            desired_state="RUNNING",
            some_other_kwarg="mykwarg",
        )

it's not really obvious that some_other_kwarg is being used as an argument to the func. What if the function definition was instead something like

def wait_till_ready(
    func, current_data, func_kwargs: Dict, desired_state, sleep_seconds=1000
)

The call to the passed function then looks almost exactly the same:

current_data = func(current_data.id, **func_kwargs).data

but the callsite is a little more clear:

wait_till_ready(
            func=self.compute_client.get_instance,
            current_data=self.instance_data,
            desired_state="RUNNING",
            func_kwargs={"some_other_kwarg": "mykwarg"},
        )

Thoughts?

@mjdonis mjdonis force-pushed the oracle-util-kwargs branch from 23b2329 to 722791a Compare January 15, 2024 09:59
@mjdonis mjdonis force-pushed the oracle-util-kwargs branch from 722791a to ccb0f78 Compare January 15, 2024 11:30
@mjdonis
Copy link
Contributor Author

mjdonis commented Jan 15, 2024

Changed the function arguments as suggested, and also added the necessary changes to the methods that use this function (and propagated the **kwargs definition to the base class and every child class to keep the signatures consistent)

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

LGTM!

@TheRealFalcon TheRealFalcon dismissed aciba90’s stale review January 15, 2024 20:35

Identified issue was addressed

@TheRealFalcon TheRealFalcon merged commit 69497c4 into canonical:main Jan 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants