erecord_vpz.models_mixins package

Submodules

erecord_vpz.models_mixins.models_mixins module

@file erecord_vpz/models_mixins.py ..

Copyright (C) 2014-2016 INRA http://www.inra.fr

This file is part of erecord - Record platform web development

License : see LICENSE file. Authors : see AUTHORS file. @include LICENSE @include AUTHORS

class erecord_vpz.models_mixins.models_mixins.AttachedToVpzActMixin[source]

Bases: object

additional methods for a model attached to a VpzAct

classmethod create(vpzact, **kwargs)[source]

create the object attached to vpzact

class erecord_vpz.models_mixins.models_mixins.VpzActMixin[source]

Bases: object

additional methods for VpzAct

get_ordered_vlepackage_list()[source]

builds and returns an ordered list about the vpzact vle package and its dependency packages.

The list elements are, for each vle package : (package name, package path name), where the vpzact vle package (ie named pkgname) is the first one.

Since the real dependency packages of the vpzact vle package are not clearly known, all the other vle packages of the vpzact models repository (ie corresponding with path vlepath) are considered as potential dependency packages.

is_old()[source]

vpzact is old if created_at ‘older’ than ACTIVITY_LIFETIME

class erecord_vpz.models_mixins.models_mixins.VpzInputMixin[source]

Bases: object

additional methods for VpzInput

class erecord_vpz.models_mixins.models_mixins.VpzOriginMixin[source]

Bases: object

additional methods for VpzOrigin

is_undefined_value_text()[source]
set_undefined_value_text()[source]
class erecord_vpz.models_mixins.models_mixins.VpzOutputMixin[source]

Bases: object

additional methods for VpzOutput

classmethod UNUSED__build_output_oname(outname)[source]

Builds and returns the oname value of an output data from its outname value.

This method is used to interpret the res content of VpzOutput in relation with the VleOut denominations (vname, oname, selection_name).

oname is the oname value of the output data as a VleOut.

outname comes from the result produced by a vle simulation (cf res of VpzOutput). outname looks like oname but is quite different (cf ‘:’ instead of ‘,’)

classmethod UNUSED__build_output_outname(oname)[source]

Builds and returns the outname value of an output data from its oname value.

This method is used to interpret the res content of VpzOutput in relation with the VleOut denominations (vname, oname, selection_name).

oname is the oname value of the output data as a VleOut.

outname comes from the result produced by a vle simulation (cf res of VpzOutput). outname looks like oname but is quite different (cf ‘:’ instead of ‘,’)

classmethod build_output_oname(outname)[source]

Builds and returns the oname value of an output data from its outname value.

This method is used to interpret the res content of VpzOutput in relation with the VleOut denominations (vname, oname, selection_name).

oname is the oname value of the output data as a VleOut.

outname comes from the result produced by a vle simulation (cf res of VpzOutput).

Identity method since oname equals outname.

classmethod build_output_outname(oname)[source]

Builds and returns the outname value of an output data from its oname value.

This method is used to interpret the res content of VpzOutput in relation with the VleOut denominations (vname, oname, selection_name).

oname is the oname value of the output data as a VleOut.

outname comes from the result produced by a vle simulation (cf res of VpzOutput).

Identity method since oname equals outname.

format_res_ok()[source]

Verifies the format of res according to plan and restype.

Returns True or False.

print_res()[source]
run(plan, restype)[source]

Runs the simulation relative to self.vpzact to define self.res

The simulation running method depends on plan (‘single’ or ‘linear’) and restype (‘dataframe’ or ‘matrix’).

Uses json result based on run_vpz simulator of erecord package

class erecord_vpz.models_mixins.models_mixins.VpzPathMixin[source]

Bases: object

additional methods for VpzPath

for_vpzact_creation()[source]

Prepares the creation of a VpzAct from a VpzPath

class erecord_vpz.models_mixins.models_mixins.VpzWorkspaceMixin[source]

Bases: erecord_vpz.models_mixins.workspace.RunhomeWorkspaceMixin, erecord_vpz.models_mixins.workspace.DatahomeWorkspaceMixin, erecord_vpz.models_mixins.workspace.ReporthomeWorkspaceMixin, erecord_vpz.models_mixins.workspace.VlehomeWorkspaceMixin, erecord_vpz.models_mixins.workspace.WorkspaceMixin

additional methods for VpzWorkspace

clean_workspace()[source]
clear_dirs()[source]
clear_workspace()[source]
define_and_build(as_vlehome=False, as_reporthome=False, as_datahome=False, as_runhome=False)[source]

Defines and builds a VpzWorkspace

Chooses/defines fields values (homepath, vlehome, reporthome, datahome, runhome) and creates the required directories (at least homepath).

A workspace may concern vlehome, reporthome, datahome, runhome. Those subdirectories will there be created or not depending on as_vlehome, as_reporthome, as_datahome, as_runhome.

get_homepath()[source]

erecord_vpz.models_mixins.transform module

@file erecord_vpz/models_mixins/transform.py ..

Copyright (C) 2014-2016 INRA http://www.inra.fr

This file is part of erecord - Record platform web development

License : see LICENSE file. Authors : see AUTHORS file. @include LICENSE @include AUTHORS

class erecord_vpz.models_mixins.transform.TransformMixin[source]

Bases: object

classmethod encode_utf8(row)[source]
classmethod make_list_line_feed()[source]

Builds and returns a list for a line feed (by row)

classmethod make_list_title(title)[source]

Builds and returns a list for title (by row)

classmethod transpose(array)[source]
class erecord_vpz.models_mixins.transform.VpzActTransformMixin[source]

Bases: erecord_vpz.models_mixins.transform.TransformMixin

additional methods for some VpzAct transformations

make_conditions_folder_xls(dirpath, bycol)[source]

Builds under dirpath the xls reports about simulation conditions

A file by row or by column, depending on bycol.

(input information)

make_experiment_conditions_sheet(ws, with_help=True)[source]

Builds experiment conditions sheet

make_experiment_in_file_xls(dirpath)[source]

Builds under dirpath the xls file about experiment

(input information)

make_experiment_out_file_xls(dirpath)[source]

Builds under dirpath the xls file about experiment

A worksheet for conditions. A worksheet for simulation results (or several in some multi-simulation cases).

(input and output information)

make_folder_csv_cond(dirpath, bycol)[source]

Builds under dirpath the csv reports about simulation conditions

(input and output information)

make_folder_csv_ident(dirpath)[source]

Builds under dirpath the csv report about identification

(input information)

make_folder_csv_output(dirpath)[source]

Builds under dirpath the csv reports about output datas values

(output information)

make_folder_txt(dirpath)[source]

Builds under dirpath the txt report

(input and output information)

make_folder_vpz(dirpath)[source]

Builds under dirpath the vpz report

make_folder_xls(dirpath, bycol)[source]

Builds under dirpath the xls report

A worksheet by theme (ident, conditions…).

(input and output information)

prepare_reports(with_general_output=True, default_general_output=False, with_out_ident_and_nicknames=True, with_res=True, with_bycol=True)[source]

Prepares information (lists) that will be used for reports building

Information comes from input and output information, but from only input information in with_general_output and with_res False case.

read_experiment_file_xls(filepath)[source]

Reads the xls filepath file about experiment

The information is read into the “conditions” sheet. The information is structured like into the file returned by a GET vpz/experiment request.

Returns (cr_ok, restype_value, plan_value, begin_value, duration_value, parameters as a dict (key,value being parameter selection_name,value), parselect_values, outselect_values.

(input information)

class erecord_vpz.models_mixins.transform.VpzInputTransformMixin[source]

Bases: erecord_vpz.models_mixins.transform.TransformMixin

additional methods for some VpzInput transformations

make_list_general()[source]

Builds and returns general information list of input information

make_list_out_ident()[source]

Builds and returns identification information of selected output datas

list_ident : output datas identification information, nicknames : nickname (shortname) according to oname

make_list_par_ident()[source]

Builds and returns identification information of selected parameters

list_ident : parameters identification information, nicknames : nickname (pname) according to selection name types : type according to selection name

make_list_par_values(nicknames, types)[source]

Builds and returns list of selected parameters values

Some names and the type of the parameter are given before its values.

make_txt_file(filename, dirpath)[source]

Builds the txt file relative to VpzInput and saves it as filename under dirpath

make_vpz_file(filename, dirpath)[source]

Builds the vpz file relative to VpzInput and saves it as filename under dirpath

class erecord_vpz.models_mixins.transform.VpzOutputTransformMixin[source]

Bases: erecord_vpz.models_mixins.transform.TransformMixin

additional methods for some VpzOutput transformations

classmethod get_indexed_name(name, simunumber=None)[source]

Returns name indexed by simunumber (name[simunumber])

classmethod get_suffixed_name(name, simunumber=None)[source]

Returns name suffixed by simunumber (name_simunumber)

classmethod make_default_list_general()[source]

Builds and returns general information list with default values

make_list_general()[source]

Builds and returns general information list of output information

make_res_compact()[source]

Builds and returns res_compact where the output datas are identified by their selection_name (as VleOut).

Has an effect only in ‘dataframe’ restype case, returns unmodified res in ‘matrix’ restype case.

If ‘dataframe’ restype case, an output data is identified into res with a key relative to its name (not exactly oname), under the key _ vname.

res (of VpzOutput) is encoded. res_compact will be encoded.

make_txt_file(filename, dirpath)[source]

Builds the txt file relative to VpzOutput and saves it as filename under dirpath

write_csv_out_values(dirpath, res)[source]

Builds under dirpath the csv reports about output datas values

res is decoded res (of VpzOutput).

Creates and fills the required csv files : one by view if ‘single’ plan, or as many as simulations if ‘linear’ plan.

csv files have headers or not according to restype case : - no header if ‘matrix’ restype. - header if ‘dataframe’ restype (same as those of vle simulation in ‘file’ mode).

(output information)

write_xls_out_values(wb, res, nicknames, sheetname='output')[source]

Writes the output datas values into xlwt.Workbook

res is decoded res (of VpzOutput).

Creates and fills the required xlwt.Worksheet : - if ‘dataframe’ restype : only one worksheet for all the views together (whichever ‘plan’ case). - if ‘matrix’ restype : one worksheet by view if ‘single’ plan, or as many as simulations if ‘linear’ plan.

Worksheets have headers or not according to restype case : - no header if ‘matrix’ restype. - header if ‘dataframe’ restype, where several names are given to identify each output data.

(output information)

erecord_vpz.models_mixins.workspace module

@file erecord_vpz/models_mixins/workspace.py ..

Copyright (C) 2014-2016 INRA http://www.inra.fr

This file is part of erecord - Record platform web development

License : see LICENSE file. Authors : see AUTHORS file. @include LICENSE @include AUTHORS

class erecord_vpz.models_mixins.workspace.DatahomeWorkspaceMixin[source]

Bases: erecord_vpz.models_mixins.workspace.WorkspaceMixin

datahome workspace

The datahome workspace is dedicated to modify the ‘data’ directory of the main vle package according to a data folder sent into the request.

Implied folders and files :

datahome = homepath / data_home
homepath / vle_home

pkg_data_path = homepath / vle_home / … / pkgname / data pkg_data_svg_path = homepath / vle_home / … / pkgname / data_original

datafolder_zip_file = homepath / data_home / datafolder.zip datafolder_src = homepath / data_home / data

pkg_data_path, pkg_data_svg_path : the ‘data’ directory of the main vle package is pkg_data_path. In some case it will be saved before modification, into pkg_data_svg_path.

datafolder_zip_file, datafolder_src : the datafolder_zip_file zip file contains the data folder sent into a request. It will be unzipped to get datafolder_src. The pkg_data_path content will be replaced or overwritten by the datafolder_src content.

clean_datahome()[source]

creates datahome after having deleted it before if necessary

clear_datahome()[source]
get_and_verify_datafolder_src_path()[source]
get_datafolder_src_path()[source]
get_datafolder_zip_file_path()[source]
get_datahome()[source]
get_pkg_data_svg_path(vle_version, pkgname)[source]
init_datahome(LOGGER, as_datahome=False)[source]
overwrite_pkg_data(data_src, vle_version, pkgname)[source]

Completes ‘data’ of the ‘pkgname’ vle package with data_src.

Completes (by overwriting) the content of the ‘data’ directory of the ‘pkgname’ vle package with the content of the data_src folder.

The vle package is located under vlehome.

replace_pkg_data(data_src, vle_version, pkgname)[source]

replaces ‘data’ of the ‘pkgname’ vle package by data_src.

Replaces the content of the ‘data’ directory of the ‘pkgname’ vle package by the content of the data_src folder, after having saved the original ‘data’ directory as pkg_data_svg_path (see get_pkg_data_svg_path).

The vle package is located under vlehome.

class erecord_vpz.models_mixins.workspace.ReporthomeWorkspaceMixin[source]

Bases: erecord_vpz.models_mixins.workspace.WorkspaceMixin

clean_reporthome()[source]
clear_reporthome()[source]
get_report_folder_path(name)[source]

Defines and return a folder path name as a reporthome subdirectory

get_reporthome()[source]
init_reporthome(LOGGER, as_reporthome=False)[source]
class erecord_vpz.models_mixins.workspace.RunhomeWorkspaceMixin[source]

Bases: erecord_vpz.models_mixins.workspace.WorkspaceMixin

clean_runhome()[source]
clear_runhome()[source]
define_and_build_runhome_subdirectory(rootname='s_')[source]
get_runhome()[source]
init_runhome(LOGGER, as_runhome=False)[source]
class erecord_vpz.models_mixins.workspace.VlehomeWorkspaceMixin[source]

Bases: erecord_vpz.models_mixins.workspace.WorkspaceMixin

build_pkg_and_its_dependencies(vpzname, vlepackage_list, vle_version)[source]

Builds into vlehome a vle package and its dependency ones.

The input vle packages are given as a list of their (package name, package path), where the first one is the main package (containing the vpz file named vpzname).

The main vle package is built as a copy, and the dependency packages as links.

About the main package : its whole ‘exp’ subdirectory is copied, even if only its vpz file vpzname is needed.

About the main package : ‘output’ subdirectory is created if not there.

Go to ‘output’ subdirectory.

clean_vlehome()[source]
clear_vlehome()[source]
get_vlehome()[source]
init_vlehome(LOGGER, as_vlehome=False)[source]
class erecord_vpz.models_mixins.workspace.WorkspaceMixin[source]

Bases: object

get_experiment_file_path()[source]
classmethod get_undefined_value()[source]
classmethod is_undefined_value(v)[source]

Module contents

erecord_vpz.models_mixins

This package is part of erecord - Record platform web development

copyright:Copyright (C) 2014-2015 INRA http://www.inra.fr.
license:GPLv3, see License for more details.
authors:see Authors.

Mixins common to models of erecord_vpz application

See erecord