How to use the jsonmodels.fields.IntField function in jsonmodels

To help you get started, we’ve selected a few jsonmodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jazzband / jsonmodels / tests / test_schema.py View on Github external
def __init__(self, some_value):
                pass

            name = fields.StringField(required=True)
            surname = fields.StringField(required=True)
            age = fields.IntField()
            toys = fields.ListField(Toy)

        class Person(models.Base):

            def __init__(self, some_value):
                pass

            name = fields.StringField(required=True)
            surname = fields.StringField(required=True)
            age = fields.IntField()
            kids = fields.ListField(Kid)
            car = fields.EmbeddedField(Car)

        schema = Person.to_json_schema()

        pattern = get_fixture('schema2.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_data_initialization.py View on Github external
def test_initialization():

    class Person(models.Base):

        name = fields.StringField()
        surname = fields.StringField()
        age = fields.IntField()
        cash = fields.FloatField()

    data = dict(
        name='Alan',
        surname='Wake',
        age=24,
        cash=2445.45,
        trash='123qwe',
    )

    alan1 = Person(**data)
    alan2 = Person()
    alan2.populate(**data)
    for alan in [alan1, alan2]:
        assert alan.name == 'Alan'
        assert alan.surname == 'Wake'
github saphetor / varsome-api-client-python / varsome_api / models / elements / broad.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from jsonmodels import models, fields

__author__ = "ckopanos"


class ExAC(models.Base):
    version = fields.StringField(help_text="Version")
    ac = fields.IntField(help_text="Allele Count", required=False, nullable=True)
    an = fields.IntField(help_text="Allele Number", required=False, nullable=True)
    ac_adj = fields.FloatField(help_text="Allele Count", required=False, nullable=True)
    an_adj = fields.FloatField(help_text="Allele Number", required=False, nullable=True)
    af = fields.FloatField(help_text="Allele Frequency", required=False, nullable=True)
    ac_afr = fields.IntField(help_text="Allele Count African", required=False, nullable=True)
    ac_amr = fields.IntField(help_text="Allele Count American", required=False, nullable=True)
    ac_asj = fields.IntField(help_text="Allele Count Ashkenazi Jewish", required=False, nullable=True)
    ac_eas = fields.IntField(help_text="Allele Count East Asian", required=False, nullable=True)
    ac_fin = fields.IntField(help_text="Allele Count European (Finnish)", required=False, nullable=True)
    ac_nfe = fields.IntField(help_text="Allele Count European (Non-Finnish)", required=False, nullable=True)
    ac_oth = fields.IntField(help_text="Allele Count Other", required=False, nullable=True)
    ac_sas = fields.IntField(help_text="Allele Count South Asian", required=False, nullable=True)
    ac_male = fields.IntField(help_text="Allele Count Male", required=False, nullable=True)
    ac_female = fields.IntField(help_text="Allele Count Female", required=False, nullable=True)
    hom = fields.IntField(help_text="Number of Homozygotes", required=False, nullable=True)
    hemi = fields.IntField(help_text="Number of Hemizygotes", required=False, nullable=True)
    ac_hom = fields.FloatField(help_text="Number of Homozygotes", required=False, nullable=True)
github saphetor / varsome-api-client-python / varsome_api / models / elements / broad.py View on Github external
an_fin = fields.IntField(help_text="Allele Number European (Finnish)", required=False, nullable=True)
    an_nfe = fields.IntField(help_text="Allele Number European (Non-Finnish)", required=False, nullable=True)
    an_oth = fields.IntField(help_text="Allele Number Other", required=False, nullable=True)
    an_sas = fields.IntField(help_text="Allele Number South Asian", required=False, nullable=True)
    an_male = fields.IntField(help_text="Allele Number Male", required=False, nullable=True)
    an_female = fields.IntField(help_text="Allele Number Female", required=False, nullable=True)
    hom_afr = fields.IntField(help_text="Number of Homozygotes African", required=False, nullable=True)
    hom_amr = fields.IntField(help_text="Number of Homozygotes American", required=False, nullable=True)
    hom_asj = fields.IntField(help_text="Number of Homozygotes Ashkenazi Jewish", required=False, nullable=True)
    hom_eas = fields.IntField(help_text="Number of Homozygotes East Asian", required=False, nullable=True)
    hom_fin = fields.IntField(help_text="Number of Homozygotes European (Finnish)", required=False, nullable=True)
    hom_nfe = fields.IntField(help_text="Number of Homozygotes European (Non-Finnish)", required=False, nullable=True)
    hom_oth = fields.IntField(help_text="Number of Homozygotes Other", required=False, nullable=True)
    hom_sas = fields.IntField(help_text="Number of Homozygotes South Asian", required=False, nullable=True)
    hom_male = fields.IntField(help_text="Number of Homozygotes Male", required=False, nullable=True)
    hom_female = fields.IntField(help_text="Number of Homozygotes Female", required=False, nullable=True)
    hemi_afr = fields.IntField(help_text="Number of Hemizygotes African", required=False, nullable=True)
    hemi_amr = fields.IntField(help_text="Number of Hemizygotes American", required=False, nullable=True)
    hemi_asj = fields.IntField(help_text="Number of Hemizygotes Ashkenazi Jewish", required=False, nullable=True)
    hemi_eas = fields.IntField(help_text="Number of Hemizygotes East Asian", required=False, nullable=True)
    hemi_fin = fields.IntField(help_text="Number of Hemizygotes European (Finnish)", required=False, nullable=True)
    hemi_nfe = fields.IntField(help_text="Number of Hemizygotes European (Non-Finnish)", required=False, nullable=True)
    hemi_oth = fields.IntField(help_text="Number of Hemizygotes Other", required=False, nullable=True)
    hemi_sas = fields.IntField(help_text="Number of Hemizygotes South Asian", required=False, nullable=True)
    af_afr = fields.FloatField(help_text="Allele Frequency African", required=False, nullable=True)
    af_amr = fields.FloatField(help_text="Allele Frequency American", required=False, nullable=True)
    af_asj = fields.FloatField(help_text="Allele Frequency Ashkenazi Jewish", required=False, nullable=True)
    af_eas = fields.FloatField(help_text="Allele Frequency East Asian", required=False, nullable=True)
    af_fin = fields.FloatField(help_text="Allele Frequency European (Finnish)", required=False, nullable=True)
    af_nfe = fields.FloatField(help_text="Allele Frequency European (Non-Finnish)", required=False, nullable=True)
    af_oth = fields.FloatField(help_text="Allele Frequency Other", required=False, nullable=True)
    af_sas = fields.FloatField(help_text="Allele Frequency South Asian", required=False, nullable=True)
github openstack / dragonflow / dragonflow / db / models / sfc.py View on Github external
@mf.register_model
@mf.construct_nb_db_model(
    indexes={
        'flow_classifiers': 'flow_classifiers',
        'port_pair_groups': 'port_pair_groups',
    },
)
class PortChain(mf.ModelBase,
                mixins.BasicEvents,
                mixins.Topic,
                mixins.Name):
    table_name = 'sfc_portchain'

    protocol = df_fields.EnumField([PROTO_MPLS])
    chain_id = fields.IntField()
    port_pair_groups = df_fields.ReferenceListField(PortPairGroup)
    flow_classifiers = df_fields.ReferenceListField(FlowClassifier)

    def find_flow_classifier(self, fc_id):
        for fc in self.flow_classifiers:
            if fc.id == fc_id:
                return fc
github allegroai / trains / trains / backend_api / session / response.py View on Github external
def is_valid(self):
        return self._is_valid

    @classmethod
    def from_raw_data(cls, status_code, text, endpoint=None):
        return cls(is_valid=False, result_code=status_code, result_subcode=0, result_msg=text,
                   endpoint=_ResponseEndpoint(name=(endpoint or 'unknown')))

    def __init__(self, is_valid=True, **kwargs):
        super(ResponseMeta, self).__init__(**kwargs)
        self._is_valid = is_valid

    id = jsonmodels.fields.StringField(required=True)
    trx = jsonmodels.fields.StringField(required=True)
    endpoint = jsonmodels.fields.EmbeddedField([_ResponseEndpoint], required=True)
    result_code = jsonmodels.fields.IntField(required=True)
    result_subcode = jsonmodels.fields.IntField()
    result_msg = jsonmodels.fields.StringField(required=True)
    error_stack = jsonmodels.fields.StringField()

    def __str__(self):
        if self.result_code == requests.codes.ok:
            return "<%d: %s/v%s>" % (self.result_code, self.endpoint.name, self.endpoint.actual_version)
        elif self._is_valid:
            return "<%d/%d: %s/v%s (%s)>" % (self.result_code, self.result_subcode, self.endpoint.name,
                                             self.endpoint.actual_version, self.result_msg)
        return "<%d/%d: %s (%s)>" % (self.result_code, self.result_subcode, self.endpoint.name, self.result_msg)
github saphetor / varsome-api-client-python / varsome_api / models / elements / icgc.py View on Github external
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from jsonmodels import models, fields

__author__ = "ckopanos"


class Occurrence(models.Base):
    affected = fields.IntField(required=False, nullable=True, help_text="Affected number")
    donors = fields.IntField(required=False, nullable=True, help_text="Donors number")
    project = fields.StringField(required=False, nullable=True, help_text="Project")


class Somatic(models.Base):
    version = fields.StringField(help_text="Version")
    id = fields.StringField(help_text="ID", required=False, nullable=True)
    occurrence = fields.ListField(required=False, nullable=True, items_types=(Occurrence, ), help_text="Occurrence")
    affected_donors = fields.IntField(help_text="Affected Donors", required=False, nullable=True)
    project_count = fields.IntField(help_text="Project Count", required=False, nullable=True)
    main_data = fields.StringField(help_text="Main data point", required=False, nullable=True)