Repository navigation
add test enforcing adapter interface - #1040
Bubballoo3 wants to merge 5 commits into
Conversation
|
This is finally passing the test, but did end up stretching a bit past what I had originally expected. Two things are worth calling out
|
| # @param owner [#to_s, Array<#to_s>] the owner(s) of the jobs | ||
| # @raise [JobAdapterError] if something goes wrong getting job info | ||
| # @return [Array<Info>] information describing submitted jobs | ||
| def info_where_owner(_, attrs: nil) |
There was a problem hiding this comment.
Doesn't a linter say this is correct?
There was a problem hiding this comment.
Yeah I could have gone either way on this, so I will update to not check names of positional args and revert this change
There was a problem hiding this comment.
Maybe check with rubocop - I'm only saying that from memory. Maybe it'll say _owner is correct, I'm not 100% sure.
|
|
||
| # Retrieve info for all jobs from the resource manager | ||
| # @return [Array<Info>] information describing submitted jobs | ||
| def info_all(attrs: nil) |
There was a problem hiding this comment.
The parent class doesn't have the host keyword. Not sure why it was implemented in linux_host - I can't find it being used in OnDemand.
ood_core/lib/ood_core/job/adapter.rb
Lines 56 to 58 in 8c5ca82
If anything we can open the interface to attrs and **kwargs but it seems unnecessary.
There was a problem hiding this comment.
Didn't scroll down far enough - you add it to the parent class.
In any case the comment I think still stands - open it up to **kwargs or remove it from the child clasess. I would probably vote for the latter as I don't see it actually being used in OnDemand.
There was a problem hiding this comment.
Yeah I might have to sit with this for a bit as I'm not sure I like either route very much. It seems kinda wrong to rip the host filtering feature out of LinuxHost and Systemd altogether when it has been there for 7ish years, but if we aren't using it then maybe nobody would care. On the flip side, a blanket **kwargs feels like it adds margin for error here, when the intent of the ticket was making the adapter interface more consistent to reduce confusion caused downstream.
Looking back, it would have been nice if it had originally been added as a separate method, like info_where_host(, but this far along I bet its about the same impact to change it as it is to rip it out altogether, the impact being that older unmaintained stuff could break
|
After thinking about this a bit more I think I want to relax the initial requirements to reduce the changes somewhat. I would be happy to drop the 'Identical interface' requirement to be instead something like 'The interface defined in the base class must be operable within all subclasses' That allows us to rename args (like |
What does this PR do?
Adds a test that rigidly verifies the expectations laid out in the adapter inheritance model. Namely that subclasses of
OodCore::Job::Adaptermust present a perfect subset of the Adapter interface. So for each public method ofAdapter, a subclass must eitherNotImplementedError.I am opening this first with just the tests to generate a failure I can refer to when I have fixed all the adapters. I do want to bring up one failure in particular, stemming from
ood_core/lib/ood_core/job/adapters/ccq.rb
Lines 107 to 123 in 8c5ca82
Which attempts to raise the
NotImplementedErrorfrom inside the subclass, rather than just allowing the base class to do the same. While this practice is not directly buggy like the original issue, I would argue that it is still not recommended, as it unnecessarily duplicates code and generally breaks the pattern I would expect, though I could begrudgingly be convinced to carve out an exception for this if we think its improper to remove this from the ccq adapter docs (even though the inline docs only mention that it will never be implemented).Related issue
Closes #1039
Testing
Checklist
Anything else?
Screenshots, context, or anything reviewers should pay close attention to.