Пример #1
0
    def fhir_validate(self, line):
        """Line magic to validate json FHIR resource(s) from iPython kernel."""
        args = magic_arguments.parse_argstring(self.fhir_validate, line)

        with grpc.insecure_channel(self.grpc_target) as channel:
            stub = wstlservice_pb2_grpc.WhistleServiceStub(channel)

            (resp, err) = _get_validation(stub, self.shell, args.version,
                                          args.input)
            if err:
                return err
            return JSON(str(json_format.MessageToDict(resp)))
Пример #2
0
 def wstl_reset(self, line):
     """Cell magic to clear all variables and functions from incremental transformation."""
     with grpc.insecure_channel(self.grpc_target) as channel:
         stub = wstlservice_pb2_grpc.WhistleServiceStub(channel)
         session_id = str(self.shell.history_manager.session_number)
         req = wstlservice_pb2.DeleteIncrementalSessionRequest(
             session_id=session_id)
         try:
             resp = stub.DeleteIncrementalSessionRequest(req)
         except grpc.RpcError as rpc_error:
             return rpc_error
         else:
             return JSON(json_format.MessageToDict(resp))
Пример #3
0
    def wstl(self, line, cell):
        """Cell magic to evaluate whistle mapping language from iPython kernel."""
        args = magic_arguments.parse_argstring(self.wstl, line)

        # TODO (b/157468786): migrate to secure channel.
        with grpc.insecure_channel(self.grpc_target) as channel:
            stub = wstlservice_pb2_grpc.WhistleServiceStub(channel)

            (incremental_session,
             err) = _get_or_create_session(stub, self.shell)
            if err:
                return err

            (transform,
             err) = _get_incremental_transform(stub, self.shell,
                                               incremental_session.session_id,
                                               args, cell)
            if err:
                return err

            result = _response_to_json(transform)
            if args.output:
                self.shell.push({args.output: result})
            return JSON(result)