Contents Menu Expand Light mode Dark mode Auto light/dark mode
mljet 0.6.0 documentation
  • Installation
  • Tutorial
    • Features
      • 1. Lightweight and versatile
      • 2. Deploy with Docker
  • Developer’s Guide
    • Cookie
    • Contrib
    • Testing
  • API Reference
    • mljet
      • mljet.contrib
        • mljet.contrib.docker_
      • mljet.cookie
        • mljet.cookie.templates
          • mljet.cookie.templates.backends
          • mljet.cookie.templates.ml
      • mljet.utils
    • mljet.contrib
      • mljet.contrib.docker_
    • mljet.cookie
      • mljet.cookie.templates
        • mljet.cookie.templates.backends
        • mljet.cookie.templates.ml
    • mljet.utils
  • Changelog
Back to top
Edit this page

mljet.cookie#

Subpackages#

  • mljet.cookie.templates
    • Subpackages
      • mljet.cookie.templates.backends
        • Submodules
        • mljet.cookie.templates.backends.dispatcher module
        • Module contents
      • mljet.cookie.templates.ml
        • Submodules
        • mljet.cookie.templates.ml.dispatcher module
        • Module contents
    • Module contents

Submodules#

mljet.cookie.cutter module#

Module that contains app builder.

exception mljet.cookie.cutter.MypyValidationError[source]#

Bases: Exception

Exception raised when the template is not passing mypy check.

args#
mljet.cookie.cutter.build_backend(template_path, methods_to_replace, methods, imports=None, ignore_mypy=False)[source]#

Build app from template.

Parameters:
  • template_path (Union[str, Path]) – path to template.

  • methods_to_replace (Sequence[str]) – methods to replace in template.

  • methods (Sequence[Callable]) – methods to replace with.

  • imports (Optional[Sequence[str]]) – imports to insert into template.

  • ignore_mypy (bool) – ignore mypy check.

Return type:

str

Returns:

Result with app source code.

Template specification:
  • template should have __main__ entrypoint.

  • template should have methods to replace, associated with passed methods.

  • template should have associated methods-endpoints.

  • template should have typing, that is pass mypy check.

Some:

Reporting intermediate ddd data such as the current trial number back to the framework, as done in MyPyValidationError.

Raises:
  • MypyValidationError – if template is not passing mypy check.

  • ValidationError – if template is not passing validation.

  • TypeError – if template is not passing validation.

  • FileNotFoundError – if template is not found.

Note

After app is built, it should be formatted with black, isort.

mljet.cookie.cutter.insert_import(text, deps)[source]#

Inserts import into text.

Parameters:
  • text (str) – text to insert import into.

  • deps (Sequence[str]) – imports to insert.

Return type:

str

Returns:

Text with inserted import.

mljet.cookie.cutter.mypy_run(text)[source]#

Run mypy check on template.

Parameters:

text (str) – Source code of template.

Return type:

str

Returns:

Result with mypy output.

mljet.cookie.cutter.replace_functions_by_names(source, names2repls)[source]#

Replace functions by names in source code with passed functions.

Return type:

str

mljet.cookie.validator module#

Static code analysis of the template.

exception mljet.cookie.validator.ValidationError[source]#

Bases: Exception

Exception raised when the template is not valid.

args#
mljet.cookie.validator.validate(source, methods)[source]#

Validate the template.

Parameters:
  • source (str) – The source code of the template

  • methods (Sequence[str]) – Sequence of the methods

Return type:

bool

Returns:

True if the template is valid, False otherwise

Module contents#

Next
mljet.cookie.templates
Previous
mljet.contrib.docker_
Copyright © 2022, Konstantin Templin & Kristina Zheltova
Made with Sphinx and @pradyunsg's Furo
On this page
  • mljet.cookie
    • Subpackages
    • Submodules
    • mljet.cookie.cutter module
      • MypyValidationError
        • MypyValidationError.args
      • build_backend()
      • insert_import()
      • mypy_run()
      • replace_functions_by_names()
    • mljet.cookie.validator module
      • ValidationError
        • ValidationError.args
      • validate()
    • Module contents