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

Inter adapter communication #36

Merged
merged 22 commits into from
Mar 18, 2019
Merged

Inter adapter communication #36

merged 22 commits into from
Mar 18, 2019

Conversation

ANeaves
Copy link
Contributor

@ANeaves ANeaves commented Mar 11, 2019

Adds the possibility for an adapter to receive references to other loaded adapters, so that it can potentially interact with those other adapters. It is designed so that this interaction is done via the GET and PUT methods as if done over HTTP, but the created ApiAdapterRequest object replaces the resource heavy HTTP request with a lightweight version that contains only what we need.

Closes #28

@ghost ghost assigned ANeaves Mar 11, 2019
@ghost ghost added the in progress label Mar 11, 2019
@ANeaves
Copy link
Contributor Author

ANeaves commented Mar 11, 2019

Created this PR even though it can't be automatically merged. Not sure what the usual tactic here is so please let me know.

@timcnicholls
Copy link
Collaborator

You can rebase your branch off master and resolve the merge conflict, then force push the branch. Rebasing public branches is regarded as a bad thing, but it's OK on a feature branch that only you are working on.

You can also just merge from master, resolve the conflict and push again. I'm never convinced which is preferable.

@coveralls
Copy link

coveralls commented Mar 11, 2019

Coverage Status

Coverage decreased (-0.09%) to 99.134% when pulling 150a904 on inter-adapter-communication into 1814ea7 on master.

@ANeaves
Copy link
Contributor Author

ANeaves commented Mar 11, 2019

The Merge Conflict was a part of the test_adapter.py file (since both me and @timcnicholls had modified the adapter class and thus the tests) but I've manually fixed that conflict and we are okay now. I was hesitant to rebase because I've broken things by doing that before and I'd rather not run the risk this time

def initialize(self, adapters):
"""Initialize the ApiAdapter after it has been registered by the API Route.

This is an abstract implimentation of the initialize mechinism that allows
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo on implementation

class ApiAdapterRequest(object):
"""API Adapter Request object.

Designed to emulate the HTTP Request Object used in the Get and Put requests
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest this should read

'Emulates the HTTPServerRequest' class passed as an argument to adapter HTTP verb methods (GET, PUT, ...)'

@@ -0,0 +1,83 @@
import logging
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid proliferation of test code source files in the main source tree I suggest we, as a minimum, merge iac_dummy.py and iac_dummy_target.py. They could also be merged into dummy.py.

@@ -0,0 +1,60 @@
import logging
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment

@@ -0,0 +1,49 @@
from nose.tools import assert_equal
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto merging these sources into one file

@timcnicholls
Copy link
Collaborator

Thanks @ANeaves for implementing this. Looks good! Comments above are minor suggestions for improvement.

Copy link
Collaborator

@timcnicholls timcnicholls left a comment

Choose a reason for hiding this comment

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

As discussed, let's refactor location and use of IAC dummy adapters. We should also allow IAC on all 'core' adapters, i.e. system_info, system_status and proxy

@ANeaves
Copy link
Contributor Author

ANeaves commented Mar 13, 2019

@timcnicholls I've merged the IAC dummy adapter into the original Dummy adapter. I also merged the tests, and removed the dummy target since it wasn't really any different from the dummy adapter that already existed.

Copy link
Collaborator

@timcnicholls timcnicholls 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 @ANeaves thanks for doing this. Have made a few very minor comments.

"""API Adapter Request object.

Emulate the HTTPServerRequest class passed as an argument to adatper HTTP
verb methods(GET, PUT etc), for internal communication between adapters.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing space before (GET, ...

@@ -1,8 +1,12 @@
""" Dummy adapter class for the ODIN server.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should now be "classes"

@@ -1,8 +1,12 @@
""" Dummy adapter class for the ODIN server.

This class implements a dummy adapter for the ODIN server, demonstrating the
The "DummyAdapter" class implements a dummy adapter for the ODIN server, demonstrating the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can remove quotes from these docstrings

Call the get method of each other adapter that is loaded and return the responses
in a dictionary.
"""
logging.debug("IAC DUMMY GET")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouty-shouty debug messages 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Debug's gotta get your attention somehow ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, but that's through the sheer force of your coding brilliance, not gratuitous use of all-caps!

Copy link
Collaborator

Choose a reason for hiding this comment

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

😆

class ApiAdapterRequest(object):
"""API Adapter Request object.

Emulate the HTTPServerRequest class passed as an argument to adatper HTTP

Choose a reason for hiding this comment

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

type: adatper

Copy link
Collaborator

@ulrikpedersen ulrikpedersen left a comment

Choose a reason for hiding this comment

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

Rubber stamp! (Apologies, I can't take too much of a close look)

I suggest at least @ajgdls should have a closer look as he is the one who works most with odin-control - and perhaps one of the other reviewers. We don't generally need the full gang for review...

for key, value in self.adapters.items():
if value is self:
del self.adapters[key]
break
Copy link
Contributor

@GDYendell GDYendell Mar 15, 2019

Choose a reason for hiding this comment

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

Suggested change
break
self.adapters = dict((k, v) for k, v in adapters.items() if v is not self)

Maybe?

Copy link
Contributor

@ajgdls ajgdls 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, the changes weren't very intrusive to the existing infrastructure which is nice.

@ANeaves ANeaves merged commit 01c51d7 into master Mar 18, 2019
@ghost ghost removed the in progress label Mar 18, 2019
@ANeaves ANeaves deleted the inter-adapter-communication branch March 18, 2019 08:52
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.

7 participants