Beispiel #1
0
def to_pickle(model, name, project=False, project_name=None):
    """
    Writes model to a pickle file.
    
    Parameters
    ----------
    model: Model object
        Model object to serialize

    name : str
        Name of the model
        
    project : bool
        Whether to write to the project folder, by default False
    """

    if not project:
        if not cfg["models"]["dir"]:  # pragma: no cover
            path = DEFAULT_MODEL_DIR
        else:
            path = cfg["models"]["dir"]
    else:
        path = os.path.join(os.path.expanduser("~"), ".aethos", "projects",
                            project_name, "app")

    _make_dir(path)

    pickle.dump(model, open(os.path.join(path, name + ".pkl"), "wb"))
Beispiel #2
0
def _make_image_dir():

    if not cfg["images"]["dir"]:
        image_dir = DEFAULT_IMAGE_DIR
    else:
        image_dir = cfg["images"]["dir"]

    _make_dir(image_dir)

    return image_dir
Beispiel #3
0
def _make_experiment_dir():  # pragma: no cover

    if not cfg["mlflow"]["dir"]:
        exp_dir = DEFAULT_EXPERIMENTS_DIR
    else:
        exp_dir = cfg["mlflow"]["dir"]

    if exp_dir.startswith('file:'):
        _make_dir(exp_dir[5:])

    return exp_dir
Beispiel #4
0
def _make_img_project_dir(model_name: str):
    """
    Make a model dir in images directory.
    
    Parameters
    ----------
    model_name : str
        Model name
    """

    _make_dir(os.path.join(IMAGE_DIR, model_name))
Beispiel #5
0
    def __init__(self, report_name):

        if not cfg["report"]["dir"]:  # pragma: no cover
            report_dir = DEFAULT_REPORT_DIR
        else:
            report_dir = cfg["report"]["dir"]

        if not cfg["images"]["dir"]:  # pragma: no cover
            self.image_dir = DEFAULT_IMAGE_DIR
        else:
            self.image_dir = cfg["images"]["dir"]

        _make_dir(report_dir)

        self.report_name = report_name
        self.docx = _global_config["word_report"]

        if os.path.exists(self.report_name):
            self.filename = self.report_name
            self.docx_filename = self.filename.replace(".txt", ".docx")

            if self.docx:  # pragma: no cover
                self.doc = Document(docx=self.docx_filename)
                style = self.doc.styles

                if not style["Indent"]:
                    style.add_style("Indent", WD_STYLE_TYPE.PARAGRAPH)
                    paragraph_format = style.paragraph_format
                    paragraph_format.left_indent = Inches(0.25)
        else:
            self.filename = "{}/{}-{}".format(
                report_dir, report_name,
                datetime.now().strftime("%d-%m-%Y_%I-%M-%S%p"))

            if self.docx:  # pragma: no cover
                self.doc = Document()
                style = self.doc.styles.add_style("Indent",
                                                  WD_STYLE_TYPE.PARAGRAPH)
                paragraph_format = style.paragraph_format
                paragraph_format.left_indent = Inches(0.25)
                self.docx_filename = self.filename + ".docx"

            self.filename += ".txt"

            self.write_header(report_name.capitalize())
            self.report_environtment()
            self.write_header('Analysis', level=2)
Beispiel #6
0
def _create_project_dir(project_dir: str, name: str):
    """
    Creates the projects directory.
    
    Parameters
    ----------
    project_dir : str
        Full path of the project dir.

    name : str
        Name of the project
    """

    project_dir = os.path.join(project_dir, name)

    _make_dir(project_dir)

    return project_dir
Beispiel #7
0
def _create_dir():
    """
    Creates the projects directory.
    
    Parameters
    ----------
    project_dir : str
        Full path of the project dir.

    name : str
        Name of the project
    """

    if not cfg["models"]["deployment_dir"]:
        dep_dir = DEFAULT_DEPLOYMENTS_DIR
    else:
        dep_dir = cfg["models"]["deployment_dir"]

    _make_dir(dep_dir)

    return dep_dir