コード例 #1
0
class TestModel(unittest.TestCase):
    def setUp(self):
        self.model_params = ModelParams({"verbose": 0})
        self.model = Model("test_model", self.model_params)

    def test_missing_params_memory(self):
        with pytest.raises(TypeError):
            Model()

    def test_missing_params_memory(self):
        with pytest.raises(TypeError):
            Model("self.model_params")

    def test_raises_not_implemented(self):
        with pytest.raises(NotImplementedError):
            self.model._init_weights()
コード例 #2
0
ファイル: views.py プロジェクト: hack2hr/hack2hr
def apiPeoplePredict(request):

    if (request.method == "OPTIONS"):
        response = JsonResponse({})
        response["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
        response["Access-Control-Allow-Origin"] = "http://13.79.21.196:8080"
        response[
            "Access-Control-Allow-Headers"] = "origin, x-requested-with, content-type, x-ijt"
        response["Access-Control-Allow-Origin"] = "*"
        return response
    body_unicode = request.body.decode('utf-8')
    jsonValue = json.loads(body_unicode)
    year = jsonValue['year']
    yearsrange = jsonValue['yearsRange']
    dataY = jsonValue['dataY']
    dataX = jsonValue['dataX']
    modelValue = jsonValue['modelValue']

    collection = db['People']
    stringForModel = []
    for doc in collection.find():
        stringForModel.append(doc)

    data = {
        "current_year": year,
        "years_to_predict": yearsrange,
        "x_params": dataX,
        "y_param": dataY,
    }

    result = Model(stringForModel, data).predict(modelValue)

    response = JsonResponse(json_util.dumps(result), safe=False)
    response["Access-Control-Allow-Origin"] = "*"
    return response
コード例 #3
0
def install_x_telegram_user():
    x_telegram_user_model = Model(
        name="Telegram User",
        model="x_telegram_user",
    )

    model_id = crud_create_model(odoo, x_telegram_user_model)

    x_name_field = crud_get_model_fields(
        odoo, [["name", "=", "x_name"], ["model_id", "=", model_id]])[0]

    x_name_field.field_description = "First Name"
    x_name_field.required = True
    x_name_field.model_id = model_id
    x_name_field.readonly = True

    crud_update_model_field(odoo, x_name_field.id, x_name_field)

    x_telegram_user_fields = [
        ModelField(
            model_id=model_id,
            name="x_user_id",
            field_description="ID",
            ttype="char",
            readonly=True,
            index=True,
        ),
        ModelField(
            model_id=model_id,
            name="x_last_name",
            field_description="Last Name",
            ttype="char",
            readonly=True,
        ),
        ModelField(
            model_id=model_id,
            name="x_username",
            field_description="Username",
            ttype="char",
            readonly=True,
        ),
        ModelField(
            model_id=model_id,
            name="x_language_code",
            field_description="Language Code",
            ttype="char",
            readonly=True,
        )
    ]

    for field in x_telegram_user_fields:
        crud_create_model_field(odoo, field)

    x_telegram_user_access = ModelAccess(
        model_id=model_id,
        name="x_telegram_user_access"
    )

    crud_create_model_access(odoo, x_telegram_user_access)
コード例 #4
0
ファイル: factories.py プロジェクト: frndlytm/metamigrate
 def make_model(self, source):
     """make_model is the Factory method. It builds
     info from source using the loader, and packages
     a template Environment from the file-system using
     the flavor.
     """
     info = self.loader.load(source)
     path = self._get_template_path()
     environ = Environment(loader=FileSystemLoader(path))
     return Model(info, TableBuilder(), environ)
コード例 #5
0
def crud_get_models(odoo: OdooRPC,
                    domain: List = [],
                    offset: int = 0,
                    limit: int = 20) -> List[Model]:
    models: List[Model] = []

    result = odoo.search_read(MODEL_NAME, domain, [], offset, limit)

    for row in result:
        models.append(Model(**row))

    return models
コード例 #6
0
ファイル: run.py プロジェクト: zdYng/MyQuantification
def main2():
    configs = json.load(open('config2.json', 'r'))

    data = DataLoader(
        os.path.join('data', configs['data']['filename']),
        configs['data']['train_test_split'],
        configs['data']['columns']
    )

    model = Model()
    model.build_model(configs)
    x, y = data.get_train_data(
        seq_len=configs['data']['sequence_length'],
        normalise=configs['data']['normalise']
    )

    # out-of memory generative training
    steps_per_epoch = math.ceil(
        (data.len_train - configs['data']['sequence_length']) / configs['training']['batch_size'])
    model.train_generator(
        data_gen=data.generate_train_batch(
            seq_len=configs['data']['sequence_length'],
            batch_size=configs['training']['batch_size'],
            normalise=configs['data']['normalise']
        ),
        epochs=configs['training']['epochs'],
        batch_size=configs['training']['batch_size'],
        steps_per_epoch=steps_per_epoch,
        save_dir=configs['model']['save_dir']
    )

    x_test, y_test = data.get_test_data(
        seq_len=configs['data']['sequence_length'],
        normalise=configs['data']['normalise']
    )

    predictions_multiseq = model.predict_sequences_multiple(x_test, configs['data']['sequence_length'],
                                                            configs['data']['sequence_length'])
    predictions_fullseq = model.predict_sequence_full(x_test, configs['data']['sequence_length'])
    predictions_pointbypoint = model.predict_point_by_point(x_test)

    plot_results_multiple(predictions_multiseq, y_test, configs['data']['sequence_length'])
    plot_results(predictions_fullseq, y_test)
    plot_results(predictions_pointbypoint, y_test)
コード例 #7
0
ファイル: x_rent_house.py プロジェクト: correaleyval/netcity
def install_x_rent_house():
    x_rent_house_model = Model(
        name="Casa de renta",
        model="x_rent_house",
    )

    model_id = crud_create_model(odoo, x_rent_house_model)

    x_name_field = crud_get_model_fields(
        odoo, [["name", "=", "x_name"], ["model_id", "=", model_id]])[0]

    x_name_field.field_description = "Nombre"
    x_name_field.required = True
    x_name_field.model_id = model_id

    crud_update_model_field(odoo, x_name_field.id, x_name_field)

    x_rent_house_fields = [
        ModelField(
            model_id=model_id,
            name="x_description",
            field_description="Descripción",
            ttype="text",
            required=True,
        ),
        ModelField(
            model_id=model_id,
            name="x_coordinates",
            field_description="GPS",
            ttype="char",
        ),
        ModelField(
            model_id=model_id,
            name="x_address",
            field_description="Dirección",
            ttype="text",
        ),
        ModelField(model_id=model_id,
                   name="x_images",
                   field_description="Fotos",
                   ttype="many2many",
                   relation="ir.attachment")
    ]

    for field in x_rent_house_fields:
        crud_create_model_field(odoo, field)

    x_rent_house_access = ModelAccess(model_id=model_id,
                                      name="x_rent_house_access")

    crud_create_model_access(odoo, x_rent_house_access)
コード例 #8
0
    def test_create_search_delete_model(self):
        model = Model(
            name="Test model",
            model="x_test_model",
        )

        model_created = crud_create_model(self.odoo, model)

        model_id = crud_search_model(self.odoo,
                                     domain=[["model", "=",
                                              "x_test_model"]])[0]

        result = crud_delete_model(self.odoo, model_id)

        self.assertEqual(type(model_created), int)
        self.assertEqual(type(model_id), int)
        self.assertEqual(result, True)
コード例 #9
0
ファイル: x_app_release.py プロジェクト: correaleyval/netcity
def install_x_app_release():
    x_app_release_model = Model(
        name="App Releases",
        model="x_app_release",
    )

    model_id = crud_create_model(odoo, x_app_release_model)

    x_name_field = crud_get_model_fields(
        odoo, [["name", "=", "x_name"], ["model_id", "=", model_id]])[0]

    x_name_field.field_description = "Nombre"
    x_name_field.required = True
    x_name_field.model_id = model_id

    crud_update_model_field(odoo, x_name_field.id, x_name_field)

    x_app_release_fields = [
        ModelField(
            model_id=model_id,
            name="x_version",
            field_description="Version",
            ttype="char",
        ),
        ModelField(
            model_id=model_id,
            name="x_description",
            field_description="Observaciones",
            ttype="text",
        ),
        ModelField(model_id=model_id,
                   name="x_apps",
                   field_description="Apps",
                   ttype="many2many",
                   relation="ir.attachment")
    ]

    for field in x_app_release_fields:
        crud_create_model_field(odoo, field)

    x_app_release_access = ModelAccess(model_id=model_id,
                                       name="x_app_release_access")

    crud_create_model_access(odoo, x_app_release_access)
コード例 #10
0
 def setUp(self):
     self.model_params = ModelParams({"verbose": 0})
     self.model = Model("test_model", self.model_params)
コード例 #11
0
 def test_missing_params_memory(self):
     with pytest.raises(TypeError):
         Model("self.model_params")
コード例 #12
0
def crud_create_model(odoo: OdooRPC, model: Model) -> int:
    result = odoo.create(MODEL_NAME, model.dict())

    return result