How to use the jsonmodels.fields 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 saphetor / varsome-api-client-python / varsome_api / models / elements / gnomad.py View on Github external
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_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)
    ac_hemi = fields.FloatField(help_text="Number of Hemizygotes", required=False, nullable=True)
    an_afr = fields.IntField(help_text="Allele Number African", required=False, nullable=True)
    an_amr = fields.IntField(help_text="Allele Number American", required=False, nullable=True)
    an_asj = fields.IntField(help_text="Allele Number Ashkenazi Jewish", required=False, nullable=True)
    an_eas = fields.IntField(help_text="Allele Number East Asian", required=False, nullable=True)
    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_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_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)
    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)
github saphetor / varsome-api-client-python / varsome_api / models / elements / sanger.py View on Github external
nullable=True)
    fathmm_mkl_non_coding_groups = fields.StringField(help_text="FATHMM_MKL non coding groups", required=False,
                                                      nullable=True)
    whole_exome_freq = fields.ListField(items_types=(str, int, float,), help_text="Whole exome frequency", required=False,
                                        nullable=True)
    whole_genome_reseq_freq = fields.ListField(items_types=(str, int, float,), help_text="Whole genome reseq frequency",
                                               required=False, nullable=True)

    resistance_mutation = fields.ListField(items_types=(str,), help_text="Resistance mutation", required=False,
                                           nullable=True)
    drug_entries = fields.ListField(items_types=(CosmicLicensedDrugEntry,), help_text="Drug entries", required=False,
                                    nullable=True)


class ComsicPublicDetails(models.Base):
    num_samples = fields.IntField(help_text='Number of samples')
    id = fields.StringField(help_text='Cosmic ID')
    is_consistent = fields.BoolField(help_text='Cosmic ID is consistent across databases')




class CosmicPublic(models.Base):
    version = fields.StringField(help_text="Version")
    items = fields.ListField(items_types=(ComsicPublicDetails, ), help_text="Details", required=False, nullable=True)


class CosmicLicensed(models.Base):
    version = fields.StringField(help_text="Version")
    items = fields.ListField(items_types=(CosmicLicensedDetails,), help_text="Details")
github openstack / dragonflow / dragonflow / db / field_types.py View on Github external
'''
    types = (netaddr.IPNetwork,)

    def parse_value(self, value):
        if value is not None:
            return netaddr.IPNetwork(value)

    def to_struct(self, obj):
        if obj is not None:
            return str(obj)


TimestampField = fields.FloatField


class MacAddressField(fields.BaseField):
    '''A field representing a MAC address, specifically a netaddr.EUI.

    In serialized form it is stored in UNIX MAC format:
        "mac": "12:34:56:78:90:ab"
    '''
    types = (netaddr.EUI,)

    def parse_value(self, value):
        if value is not None:
            return netaddr.EUI(value, dialect=netaddr.mac_unix_expanded)

    def to_struct(self, obj):
        if obj is not None:
            obj.dialect = netaddr.mac_unix_expanded
            return str(obj)
github saphetor / varsome-api-client-python / varsome_api / models / elements / broad.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 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)
github saphetor / varsome-api-client-python / varsome_api / models / elements / uniprot.py View on Github external
from jsonmodels import models, fields

__author__ = "ckopanos"


class UniprotVariantsDetails(models.Base):
    annotation_id = fields.StringField(help_text="Annotation ID", required=False, nullable=True)
    protein_id = fields.StringField(help_text="Protein ID", required=False, nullable=True)
    bed_comments = fields.ListField(help_text="Comments", items_types=(str, ), required=False, nullable=True)
    gene = fields.StringField(help_text="Gene", required=False, nullable=True)
    variant_type = fields.StringField(help_text="Variant type", required=False, nullable=True)
    transcripts = fields.ListField(help_text="Transcripts", items_types=(str,), required=False, nullable=True)
    pub_med_references = fields.ListField(help_text="PubMed References", items_types=(int,), required=False, nullable=True)
    disease = fields.StringField(help_text="Disease", required=False, nullable=True)
    disease_symbol = fields.StringField(help_text="Disease symbol", required=False, nullable=True)
    disease_alt_symbol = fields.StringField(help_text="Disease alt symbol", required=False, nullable=True)


class UniprotVariants(models.Base):
    version = fields.StringField(help_text="Version")
    items = fields.ListField(help_text='Details', items_types=(UniprotVariantsDetails,))
github saphetor / varsome-api-client-python / varsome_api / models / elements / thousand_genomes.py View on Github external
__author__ = "ckopanos"


class ThousandGenomes(models.Base):
    version = fields.StringField(help_text="Version")
    ac = fields.ListField(items_types=(int,), help_text="Allele Count", required=False, nullable=True)
    af = fields.ListField(items_types=(float,), help_text="Allele Frequency", required=False, nullable=True)
    an = fields.ListField(items_types=(int,), help_text="Allele Number", required=False, nullable=True)
    ns = fields.ListField(items_types=(int,), help_text="Number of Samples", required=False, nullable=True)
    afr_af = fields.ListField(items_types=(float,), help_text="Allele Frequency African", required=False, nullable=True)
    amr_af = fields.ListField(items_types=(float,), help_text="Allele Frequency American", required=False,
                              nullable=True)
    eas_af = fields.ListField(items_types=(float,), help_text="Allele Frequency East Asian", required=False,
                              nullable=True)
    eur_af = fields.ListField(items_types=(float,), help_text="Allele Frequency European", required=False,
                              nullable=True)
    sas_af = fields.ListField(items_types=(float,), help_text="Allele Frequency South Asian", required=False,
                              nullable=True)
    main_data = fields.StringField(help_text="Main data point", required=False, nullable=True)
github openstack / dragonflow / dragonflow / db / models / l3.py View on Github external
network = df_fields.IpNetworkField()


@mf.register_model
@mf.construct_nb_db_model
class LogicalRouter(mf.ModelBase, mixins.Name, mixins.Version, mixins.Topic,
                    mixins.UniqueKey, mixins.BasicEvents):
    """Define the dragonflow db model for logical router.

    Note that only the fields that dragonflow has used are defined here.
    Fields like 'distributed' and 'external_gateway' are missed on purpose.
    """
    table_name = "lrouter"

    ports = fields.ListField(LogicalRouterPort)
    routes = fields.ListField(host_route.HostRoute)

    def add_router_port(self, router_port):
        self.ports.append(router_port)

    def remove_router_port(self, router_port_id):
        for idx, router_port in enumerate(self.ports):
            if router_port.id == router_port_id:
                self.ports.pop(idx)


@mf.register_model
@mf.construct_nb_db_model(
    indexes={
        'lport': 'lport.id',
        'floating_lport': 'floating_lport.id',
    },
github openstack / dragonflow / dragonflow / db / models / core.py View on Github external
@mf.construct_nb_db_model
class Chassis(mf.ModelBase, mixins.BasicEvents):
    table_name = 'chassis'

    ip = df_fields.IpAddressField(required=True)
    external_host_ip = df_fields.IpAddressField()
    tunnel_types = df_fields.EnumListField(conf.CONF.df.tunnel_types,
                                           required=True)


@mf.register_model
@mf.construct_nb_db_model
class Publisher(mf.ModelBase, mixins.Name):
    table_name = 'publisher'
    uri = fields.StringField()
    last_activity_timestamp = fields.FloatField()

    def is_stale(self):
        timeout = conf.CONF.df.publisher_timeout
        return (time.time() - self.last_activity_timestamp) > timeout

    @classmethod
    def on_get_all_post(self, instances):
        return [o for o in instances if not o.is_stale()]


@mf.register_model
@mf.construct_nb_db_model
class Listener(mf.ModelBase):
    table_name = "listener"

    timestamp = df_fields.TimestampField()