Esempio n. 1
0
def test_call_factory(plugin_package):
    """Test that the call factory can retrieve call in package"""
    plugin_name = "plugin_parts"
    call = pyplugs.call_factory(plugin_package)
    factory_call = call(plugin_name)
    pyplugs_call = pyplugs.call(plugin_package, plugin=plugin_name)
    assert factory_call == pyplugs_call
A pipeline defines one set of behaviors for the `{{ cookiecutter.exe_name }}` script.

Each pipeline is defined as a PyPlugs plug-in
"""

# Third party imports
import munch
import pyplugs
from codetiming import Timer

# {{ cookiecutter.project_name }} imports
from {{ cookiecutter.repo_name }} import config
from {{ cookiecutter.repo_name }}.utils.log import logger

# Set up plug-in functions
call = pyplugs.call_factory(__package__)
funcs = pyplugs.funcs_factory(__package__)


@logger.catch(reraise=True)  # Log exceptions with more details
@Timer("pipeline", "Finished pipeline in {:.2f} seconds", logger=logger.time)
def run(pipeline: str, *stages) -> None:
    """Run one pipeline

    Args:
        pipeline:  Name of pipeline
    """

    # Run pipeline
    stages = stages or config.{{ cookiecutter.repo_name }}.pipelines[pipeline].stages or funcs(pipeline)
    logger.opt(colors=True).info(
Esempio n. 3
0
"""Plugins for reading configuration file formats

"""

# Standard library imports
import pathlib
from typing import Any, Dict, Optional, Tuple

# Third party imports
import pyplugs

# PyConfs imports
from pyconfs import formats

names = pyplugs.names_factory(__package__)
from_str = pyplugs.call_factory(__package__)


def from_file(file_path: pathlib.Path,
              file_format: Optional[str] = None,
              encoding: str = "utf-8",
              **reader_args: Any) -> Tuple[str, Dict[str, Any]]:
    """Read a configuration from file with the given format

    If the file format is not specified, it is deduced from the file path suffix.
    """
    file_format = (formats.guess_format(file_path)
                   if file_format is None else file_format)
    return file_format, from_str(file_format,
                                 string=file_path.read_text(encoding=encoding),
                                 **reader_args)
Esempio n. 4
0
"""Geo:N:G report generators"""

# Third party imports
import pyplugs

generate = pyplugs.call_factory(__package__)