mloq.writer#

The writer module defines the Writer class, which is in charge of creating the files and directories specified in the CMDRecord.

Module Contents#

Classes#

Writer

Write all the files specified on the provided CMDRecord.

class mloq.writer.Writer(path, record, overwrite=False)[source]#

Write all the files specified on the provided CMDRecord.

This class fills in rendered templates according to the provided configuration and generates the resulting file on the specified folder.

Attributes of this class:
path: Path string describing the destination folder where the

file will be created.

ledger: Instance of the Ledger class. It contains a dictionary

summarizing the files that will by generated by mloq.

record: Instance of the CMDRecord class. It keeps track of all

files and directories that will be created from the user’s configuration.

overwrite: Boolean value. If True, existing files will be rewritten

by mloq application.

Parameters
property path#

Path string describing the location where the files will be generated.

Return type

pathlib.Path

property ledger#

Keep track of the generated files.

Return type

mloq.record.Ledger

property record#

Register the files and directories generated by the mloq application.

Return type

mloq.record.CMDRecord

create_directories()[source]#

Create the folders registered inside the attribute ‘record.directories’.

Return type

None

write_templates()[source]#

Generate the files recorded in the attribute ‘record.files’ on the specified path.

Return type

None

dump_ledger()[source]#

Write the summary of the generated files.

This method collects the elements stored in ledger to create a markdown document that summarizes all the files generated by the MLOQ application.

Return type

None

write_template(file, path, config)[source]#

Create new file containing the rendered template configuration.

Parameters
  • file (mloq.files.File) – File object representing the jinja template that will be rendered.

  • path (pathlib.Path) – Target folder where the generated files will be written.

  • config (omegaconf.DictConfig) – DictConfig containing the selected project configuration.

Returns

None.

Return type

None

run()[source]#

Generate all files and directories registered inside the record instance.

Return type

None