Underlying plumbing/infrastructure for Porter CLI/RestApp#2713
Underlying plumbing/infrastructure for Porter CLI/RestApp#2713derekpierre merged 11 commits intonucypher:porterfrom
Conversation
4743688 to
6ccf22c
Compare
|
There is now a simple CLI available and a WebController. Of course, any actual Porter functionality on behalf of Alice/Bob is only stubbed out and not implemented. However, the control infrastructure allows for implicit CLI options, and rest endpoints to be appropriately mapped. $ nucypher porter --help
Usage: nucypher porter [OPTIONS] COMMAND [ARGS]...
Porter management commands. Porter is the conduit between web apps and the
nucypher network, that performs actions on behalf of Alice and Bob.
Options:
--help Show this message and exit.
Commands:
exec-work-order Execute a PRE work order on behalf of Bob.
get-treasure-map Retrieve a treasure map on behalf of Bob.
get-ursulas Sample Ursulas on behalf of Alice.
publish-treasure-map Publish a treasure map on behalf of Alice.
revoke Off-chain revoke of a policy on behalf of Alice.
run Start Porter's Web controller.And a very simple HTTP Web controller that can be run: (In parallel) |
|
Filed follow-up issue #2714 for reviewing the inconsistencies with some of the original character controls fields. |
983354e to
17e3088
Compare
| from nucypher.utilities.porter.control.interfaces import PorterInterface | ||
|
|
||
|
|
||
| class Porter(Learner): |
There was a problem hiding this comment.
Naming things: Are we settled on "Porter"?
There was a problem hiding this comment.
Nope - can be changed. That's just what we've been calling it up until now. Even if we like the name, this learner class does not need to be called Porter.
| self.interface = self._interface_class(porter=self) | ||
| self.controller = NO_CONTROL_PROTOCOL | ||
| if controller: | ||
| # TODO need to understand this better - only made it analogous to what was done for characters |
There was a problem hiding this comment.
Is there any scernerio where you'd want to programmatically use a Porter instance without the CLI?
There was a problem hiding this comment.
This was the thing I wasn't sure about. Characters eg. Alice, Bob seem to also use this same code block when is_me is True, and it was unclear to me why they would do that, when they may be used without the CLI.
72e7646 to
4cafbf4
Compare
…racter control" into a general "base control" from which "character control" can sub-class.
…rafted a very simple run command for the Porter CLI.
… were incorrect or over-engineered.
4cafbf4 to
76a2420
Compare
Type of PR:
Required reviews:
What this does:
This refactoring will facilitate a non-character learner like "Porter" to utilize the existing schema/controllers infrastructure for REST-like endpoints.
A lot of prior work was done for CLI/JSON/Web controllers and verification of inputs via schema definitions for the "character control" that can be reused for Porter. However, Porter isn't a character, so some of the plumbing needs to be modified to allow for the possibility of a non-character utilizing the same infrastructure. I think of it as just a base control for that maps to an interface and the underlying implementation of that interface may be a character (eg. Alice, Bob etc.) or not (eg. Porter).
Chatted with @vepkenez and @KPrasch about it yesterday.
Once that refactoring is done, Porter can benefit from the ease of utilizing a CLIConroller and a WebController with built-in function mapping and parameter validation.
Closes #2702 .
Closes #2668.