Skip to content

Extract ComputationAction from OperationMessage#3132

Merged
Jasopaum merged 22 commits intoOpenMined:masterfrom
karlhigley:refactor/actions
Mar 9, 2020
Merged

Extract ComputationAction from OperationMessage#3132
Jasopaum merged 22 commits intoOpenMined:masterfrom
karlhigley:refactor/actions

Conversation

@karlhigley
Copy link
Contributor

@karlhigley karlhigley commented Mar 2, 2020

An early step toward #3008. Depends on OpenMined/syft-proto#47.

@karlhigley
Copy link
Contributor Author

karlhigley commented Mar 3, 2020

@Jasopaum Operation and OperationMessage now have separate (but related) msgpack serialization methods. The next step is to extract Operation's Protobuf serialization from the existing methods on OperationMessage into new methods on Operation.

@karlhigley karlhigley requested a review from Jasopaum March 3, 2020 02:36
@karlhigley karlhigley changed the title WIP Extract Operation (or ComputationAction?) from OperationMessage [WIP] Extract Operation (or ComputationAction?) from OperationMessage Mar 3, 2020
@karlhigley karlhigley changed the title [WIP] Extract Operation (or ComputationAction?) from OperationMessage [WIP] Extract ComputationAction from OperationMessage Mar 4, 2020
return (message, self.action.return_ids)

@staticmethod
def simplify(worker: AbstractWorker, ptr: "OperationMessage") -> tuple:
Copy link
Member

Choose a reason for hiding this comment

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

Are we planning to keep "simplify" and "detail' around long term given Protobuf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but they still need to work for the time being since Protobuf serialization isn’t complete yet.

sy.serde.protobuf.proto.set_protobuf_id(protobuf_op.return_ids.add(), return_id)

protobuf_op_msg.operation.CopyFrom(protobuf_op)
protobuf_op = ComputationAction.bufferize(worker, operation_message.action)
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 an intentional design choice in "bufferize" being used functionally instead of as a method on operation_message.action?

Copy link
Member

Choose a reason for hiding this comment

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

(not a big deal)

Copy link
Contributor Author

@karlhigley karlhigley Mar 8, 2020

Choose a reason for hiding this comment

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

Yes, there is, but it originally comes from msgpack serialization. If I recall correctly, it’s because there’s no object to call detail/unbufferize on; the object is the output of those methods (rather than an input.) As a result, those methods have to be static, and making simplify/bufferize static too creates a parallel structure for serialization in both directions.

Copy link
Member

@iamtrask iamtrask left a comment

Choose a reason for hiding this comment

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

I left some light questions but nothing blocking.

@karlhigley karlhigley changed the title [WIP] Extract ComputationAction from OperationMessage Extract ComputationAction from OperationMessage Mar 8, 2020
@karlhigley karlhigley requested a review from iamtrask March 9, 2020 12:47
Copy link
Member

@Jasopaum Jasopaum left a comment

Choose a reason for hiding this comment

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

Still need to change the syft-proto requirement but otherwise, LGTM

Copy link
Contributor

@LaRiffle LaRiffle left a comment

Choose a reason for hiding this comment

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

If I read correctly your msg from syft-core, and those actions should be more specifically ComputationAction?
Or do we allow for communication in plan.actions?
Based on your terminology, I'm 100% ok to rephrase all the attributes on plan.py when we're set on the naming.

@karlhigley
Copy link
Contributor Author

karlhigley commented Mar 9, 2020

@LaRiffle Yeah, the actions in Plans can only be ComputationActions. That restriction is captured in the type annotations in __init__(), but I didn't want to make the name of the property super-long and inconvenient.

I suppose we could also build in a guard clause that would prevent other types from being passed in as actions or something. 🤔

@karlhigley
Copy link
Contributor Author

(Rebased this PR on top of the Plan changes in #3080.)

@Jasopaum Jasopaum merged commit f6c7d76 into OpenMined:master Mar 9, 2020
@karlhigley karlhigley added this to the Syft 0.3 milestone Mar 14, 2020
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.

4 participants