示例#1
0
class ModelRequestMessage(Message):
    sample_ids = repeated(Int(description='Sample IDs'))
    model_id = String(description='Model ID (f.e. iJO1366)')
    phase_id = Int(description='Phase ID')
    map = String(description='Name of map to show')
    method = String(description='Simulation method to run')
    with_fluxes = Bool(description='Add flux information to  the response')
    objective = String(description='Reaction ID to be set as objective')
示例#2
0
class PhasePlaneMessage(Message):
    objective_upper_bound = repeated(
        Float32(description='Upper bound for theoretical yield objective'))
    objective_lower_bound = repeated(
        Float32(description='Lower bound for theoretical yield objective'))
    objective = repeated(Float32(description='Theoretical objective values'))
    objective_id = String(description='Objective reaction ID')
示例#3
0
        class QueryResponse(Message):
            class Meta:
                description = 'Information about pets'

            ids = repeated(Field(Pet, description='Bunch of pets'))
            pet = Field(Pet, description='The other pet')
            repeat = repeated(String(description='Bunch of strings'))
示例#4
0
class ParameterMessage(Message):
    in_ = String(json_name='in')  # TODO: enum
    description: str
    required: bool
    name: str
    type: str
    items: SchemaMessage
    schema: SchemaMessage
示例#5
0
class ModelMessage(Message):
    model_id = String(
        description=
        'The saved model ID which can be used for retrieving cached information'
    )
    fluxes = map_(
        Float32())  # TODO: fix not implemented while trying to add description
    growth_rate = Float32(description='Growth rate for this simulation')
    model: JSONValue
示例#6
0
class ErrorResponse(Message):
    status = Int32()
    description = String()

    # TODO Repeat(String)
    path = String()

    # TODO helper for raising errors
    def raise_(self):
        if self.status == 501:
            raise NotImplemented_()
        # if self.status == 500:
        #         raise ServerError(self.message or '')
        #     if self.status == 404:
        #         raise NotFound(self.message or '')

        raise RuntimeError('HTTP status {}: {}'.format(self.status,
                                                       self.description))
示例#7
0
class MeasurementMessage(Message):
    type = String(
        description=
        'The subject of the measurement, e.g. "compound", "protein" or "reaction"'
    )
    id = Int(
        description=
        'identifier associated with the measured subject, e.g. metabolite identifier'
    )
    name = String(description='In case of metabolite, human-readable name')
    db_name = String(
        description=
        'In case of xref data, the miriam name of the database, e.g. uniprot')
    mode = String(
        description='Quantification mode, e.g. "relative" or "quantitative"')
    measurements = repeated(
        Float32(description='Measurements taken during the experiment'))
    units = MapField(str, description='Units in which measurements are taken')
    rate = String(description='Rate')
示例#8
0
class SchemaMessage(Schema):
    ref = String(json_name='$ref')

    type: str  # TODO: enum
    description: str

    items = Field('venom.rpc.reflect.openapi.SchemaMessage')

    properties = MapField('venom.rpc.reflect.openapi.SchemaMessage')
    additional_properties = Field('venom.rpc.reflect.openapi.SchemaMessage')
示例#9
0
    async def test_magic_request_message_auto_unpack(self):
        def func(self, value: str) -> StringValue:
            return StringValue(value)

        inspect = magic_normalize(func, auto_generate_request=True)
        self.assertEqual(inspect.response, StringValue)
        self.assertEqual(inspect.request.__meta__.name, 'FuncRequest')
        self.assertEqual(fields(inspect.request), (
            String(name='value'),
        ))
        # TODO StringValue() should be equal to StringValue('')
        self.assertEqual(await inspect.invokable(None, inspect.request()), StringValue(''))
        self.assertEqual(await inspect.invokable(None, inspect.request('foo')), StringValue('foo'))
示例#10
0
    def test_stub_rpc_response_repeat_auto(self):
        class GreeterStub(Stub):
            @rpc(auto=True)
            def get_greetings(self) -> List[str]:
                raise NotImplementedError

        self.assertEqual(GreeterStub.get_greetings.response.__meta__.name,
                         'GetGreetingsResponse')
        self.assertEqual(tuple(fields(GreeterStub.get_greetings.response)),
                         (repeated(String(), name='values')))

        self.assertEqual(GreeterStub.greet.response, StringValue)
        self.assertEqual(GreeterStub.greet.name, 'get_greetings')
示例#11
0
    def test_stub_rpc_request_repeat_auto(self):
        class GreeterStub(Stub):
            @rpc(auto=True)
            def greet_many(self, names: List[str]) -> str:
                raise NotImplementedError

        self.assertEqual(GreeterStub.greet_many.request.__meta__.name,
                         'GreetManyRequest')
        self.assertEqual(tuple(fields(GreeterStub.greet_many.request)),
                         (repeated(String(), name='names'), ))

        self.assertEqual(GreeterStub.greet_many.response, StringValue)
        self.assertEqual(GreeterStub.greet_many.name, 'greet_many')
示例#12
0
    def test_stub_rpc_request_auto(self):
        class GreeterStub(Stub):
            @rpc(auto=True)
            def greet(self, name: str, shout: bool = False) -> str:
                raise NotImplementedError

        self.assertEqual(GreeterStub.greet.request.__meta__.name,
                         'GreetRequest')
        self.assertEqual(tuple(fields(GreeterStub.greet.request)), (
            String(name='name'),
            Bool(name='shout'),
        ))

        self.assertEqual(GreeterStub.greet.response, StringValue)
        self.assertEqual(GreeterStub.greet.name, 'greet')
示例#13
0
    def test_message_type_hints(self):
        class Pet(Message):
            sounds: List[str]
            size: float
            speed: int
            age: int

        self.assertIsInstance(Pet.__fields__, OrderedDict)
        self.assertEqual(('sounds', 'size', 'speed', 'age'),
                         tuple(Pet.__fields__.keys()))
        self.assertEqual(
            {
                'sounds': repeated(String(), name='sounds'),
                'size': Field(float, name='size'),
                'speed': Field(int, name='speed'),
                'age': Field(int, name='age')
            }, Pet.__fields__)
示例#14
0
 def test_field_string(self):
     self.assertEqual(String(), Field(str))
示例#15
0
 class Pet(Message):
     id = Int()
     name = String()
     tag = String()
示例#16
0
 class FooInner(Message):
     i = String()
示例#17
0
        class Pet(Message):
            class Meta:
                description = 'Very important object'

            pet_id = String(description='Pet ID to query')
示例#18
0
 class Pet(Message):
     sound = String()
示例#19
0
 class Pet(Message):
     sounds = repeated(String())
示例#20
0
class HelloRequest(Message):
    name = String()
示例#21
0
class ExperimentMessage(Message):
    id = Int(description='Experiment ID')
    name = String(description='Experiment name')
示例#22
0
class ExperimentsRequestMessage(Message):
    taxon_code = String(
        descripton=
        'Species five-letter mnemonic short_code that must be associated with at least one '
        'sample belonging to the  experiment')
示例#23
0
class HelloResponse(Message):
    message = String()
示例#24
0
class SampleModelsMessage(Message):
    response = repeated(String(description='Possible models for the sample'))
示例#25
0
class PhaseMessage(Message):
    id = Int(description='Phase ID')
    name = String(description='Phase name')
示例#26
0
class MetaboliteMediumMessage(Message):
    id = Int(description='Metabolite ID')
    name = String(description='Metabolite human-readable name')
    concentration = Float32(description='Concentration in medium')
示例#27
0
 class HelloRequest(Message):
     name = String()
     shout = Bool()
示例#28
0
 class Foo(Message):
     string = String()
示例#29
0
class SampleMessage(Message):
    id = repeated(Int(description='Sample IDs'))
    name = String(description='Sample name')
    organism = String(description='Organism short code')
示例#30
0
class SampleInfoMessage(Message):
    genotype_changes = repeated(
        String(description='Gnomic strings for genotype changes'))
    measurements = repeated(MeasurementMessage)
    medium = repeated(MetaboliteMediumMessage)