Skip to content

Underlying plumbing/infrastructure for Porter CLI/RestApp#2713

Merged
derekpierre merged 11 commits intonucypher:porterfrom
derekpierre:control-refactoring
Jun 9, 2021
Merged

Underlying plumbing/infrastructure for Porter CLI/RestApp#2713
derekpierre merged 11 commits intonucypher:porterfrom
derekpierre:control-refactoring

Conversation

@derekpierre
Copy link
Member

@derekpierre derekpierre commented May 26, 2021

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

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.

@derekpierre derekpierre added this to the Porter v1 (MVP) milestone May 26, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request May 26, 2021
@derekpierre derekpierre changed the title [WIP] Abstract what is now "Character Control" specific into a general "base control" from which "character control" can sub-class [WIP] Underlying plumbing/infrastructure for Porter CLI/RestApp May 26, 2021
@derekpierre derekpierre requested review from KPrasch and vepkenez May 27, 2021 16:17
@derekpierre derekpierre changed the base branch from main to porter May 27, 2021 16:20
derekpierre added a commit to derekpierre/nucypher that referenced this pull request May 27, 2021
@derekpierre derekpierre force-pushed the control-refactoring branch 2 times, most recently from 4743688 to 6ccf22c Compare May 27, 2021 16:30
@derekpierre derekpierre self-assigned this May 27, 2021
@derekpierre derekpierre requested a review from cygnusv May 27, 2021 20:21
@derekpierre
Copy link
Member Author

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:

$ nucypher porter run --provider https://mainnet.infura.io/v3/<app_id> --network mainnet


 ______
(_____ \           _
 _____) )__   ____| |_  ____  ____
|  ____/ _ \ / ___)  _)/ _  )/ ___)
| |   | |_| | |   | |_( (/ /| |
|_|    \___/|_|    \___)____)_|

the conduit between web apps and the nucypher network

Network: Mainnet
Provider: https://mainnet.infura.io/v3/<app_id>
Running Porter Web Controller at http://localhost:9155

(In parallel)

$ curl http://localhost:9155/get_ursulas
{'quantity': ['Missing data for required field.'], 'duration_periods': ['Missing data for required field.']}

@derekpierre derekpierre changed the title [WIP] Underlying plumbing/infrastructure for Porter CLI/RestApp Underlying plumbing/infrastructure for Porter CLI/RestApp May 27, 2021
@derekpierre derekpierre marked this pull request as ready for review May 27, 2021 20:23
@derekpierre
Copy link
Member Author

Filed follow-up issue #2714 for reviewing the inconsistencies with some of the original character controls fields.

@derekpierre derekpierre linked an issue May 28, 2021 that may be closed by this pull request
@derekpierre derekpierre force-pushed the control-refactoring branch from 983354e to 17e3088 Compare May 31, 2021 13:19
from nucypher.utilities.porter.control.interfaces import PorterInterface


class Porter(Learner):
Copy link
Member

Choose a reason for hiding this comment

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

Naming things: Are we settled on "Porter"?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Is there any scernerio where you'd want to programmatically use a Porter instance without the CLI?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

derekpierre added a commit to derekpierre/nucypher that referenced this pull request May 31, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jun 1, 2021
@derekpierre derekpierre force-pushed the control-refactoring branch from 72e7646 to 4cafbf4 Compare June 1, 2021 13:23
@derekpierre derekpierre requested a review from jMyles June 4, 2021 19:38
@derekpierre derekpierre force-pushed the control-refactoring branch from 4cafbf4 to 76a2420 Compare June 7, 2021 14:49
@derekpierre derekpierre merged commit da11222 into nucypher:porter Jun 9, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 7, 2021
derekpierre added a commit to derekpierre/nucypher that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 12, 2021
derekpierre added a commit that referenced this pull request Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI This effects the nucypher CLI Web Webpages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST App/CLI built around Porter "Learner"

4 participants