How to use cobald - 10 common examples

To help you get started, we’ve selected a few cobald examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")
github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
cpu_cores = getattr(configuration, site.name).MachineMetaData[machine_type][
                "Cores"
            ]
            site_composites.append(
                Logger(
                    Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")
github MatterMiners / tardis / tardis / configuration / configuration.py View on Github external
def translate_config(obj):
    if isinstance(obj, AttributeDict):
        translated_obj = AttributeDict(obj)
        for key, value in obj.items():
            if key == "user_data":  # base64 encode user data
                with open(os.path.join(os.getcwd(), obj[key]), "rb") as f:
                    translated_obj[key] = b64encode(f.read())
            elif key == "__type__":  # do legacy object initialisation
                return Translator().translate_hierarchy(obj)
            else:
                translated_obj[key] = translate_config(value)
        return translated_obj
    elif isinstance(obj, list):
        return [translate_config(item) for item in obj]
    else:
        return obj
github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
)
            cpu_cores = getattr(configuration, site.name).MachineMetaData[machine_type][
                "Cores"
            ]
            site_composites.append(
                Logger(
                    Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")
github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
for resource_attributes in check_pointed_resources
            ]

            # create drone factory for COBalD FactoryPool
            drone_factory = partial(
                create_drone,
                site_agent=site_agent,
                batch_system_agent=batch_system_agent,
                plugins=plugins.values(),
            )
            cpu_cores = getattr(configuration, site.name).MachineMetaData[machine_type][
                "Cores"
            ]
            site_composites.append(
                Logger(
                    Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")
github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
]

            # create drone factory for COBalD FactoryPool
            drone_factory = partial(
                create_drone,
                site_agent=site_agent,
                batch_system_agent=batch_system_agent,
                plugins=plugins.values(),
            )
            cpu_cores = getattr(configuration, site.name).MachineMetaData[machine_type][
                "Cores"
            ]
            site_composites.append(
                Logger(
                    Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")
github MatterMiners / tardis / tardis / configuration / configuration.py View on Github external
for key, value in obj.items():
            if key == "user_data":  # base64 encode user data
                with open(os.path.join(os.getcwd(), obj[key]), "rb") as f:
                    translated_obj[key] = b64encode(f.read())
            elif key == "__type__":  # do legacy object initialisation
                return Translator().translate_hierarchy(obj)
            else:
                translated_obj[key] = translate_config(value)
        return translated_obj
    elif isinstance(obj, list):
        return [translate_config(item) for item in obj]
    else:
        return obj


@plugin_constraints(before={"pipeline"})
class Configuration(Borg):
    _shared_state = AttributeDict()

    def __init__(self, configuration: [str, dict] = None):
        super(Configuration, self).__init__()
        if configuration:
            if isinstance(configuration, str):  # interpret string as file name
                self.load_config(configuration)
            else:
                self.update_config(configuration)

    def load_config(self, config_file: str) -> None:
        """
        Loads YAML configuration file into shared state of the configuration borg
        :param config_file: The name of the configuration file to be loaded
        :type config_file: str
github MatterMiners / tardis / tardis / adapters / sites / cloudstack.py View on Github external
def __init__(self, machine_type: str, site_name: str):
        self._configuration = getattr(Configuration(), site_name)
        self.cloud_stack_client = CloudStack(
            end_point=self._configuration.end_point,
            api_key=self._configuration.api_key,
            api_secret=self._configuration.api_secret,
            event_loop=runtime._meta_runner.runners[asyncio].event_loop,
        )
        self._machine_type = machine_type
        self._site_name = site_name

        key_translator = StaticMapping(
            remote_resource_uuid="id", drone_uuid="name", resource_status="state"
        )

        translator_functions = StaticMapping(
            created=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z"),
            updated=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z"),
            state=lambda x, translator=StaticMapping(
                Present=ResourceStatus.Booting,
                Running=ResourceStatus.Running,
                Stopped=ResourceStatus.Stopped,
                Expunged=ResourceStatus.Deleted,
github MatterMiners / tardis / tardis / resources / drone.py View on Github external
from tardis.interfaces.plugin import Plugin
from tardis.interfaces.state import State
from .dronestates import RequestState
from .dronestates import DownState
from ..utilities.attributedict import AttributeDict
from cobald.daemon import service
from cobald.interfaces import Pool

from datetime import datetime

import asyncio
import logging
import uuid


@service(flavour=asyncio)
class Drone(Pool):
    def __init__(
        self,
        site_agent: SiteAgent,
        batch_system_agent: BatchSystemAgent,
        plugins: Optional[List[Plugin]] = None,
        remote_resource_uuid=None,
        drone_uuid=None,
        state: RequestState = RequestState(),
        created: float = None,
        updated: float = None,
    ):
        self._site_agent = site_agent
        self._batch_system_agent = batch_system_agent
        self._plugins = plugins or []
        self._state = state
github MatterMiners / tardis / tardis / resources / poolfactory.py View on Github external
)
                for resource_attributes in check_pointed_resources
            ]

            # create drone factory for COBalD FactoryPool
            drone_factory = partial(
                create_drone,
                site_agent=site_agent,
                batch_system_agent=batch_system_agent,
                plugins=plugins.values(),
            )
            cpu_cores = getattr(configuration, site.name).MachineMetaData[machine_type][
                "Cores"
            ]
            site_composites.append(
                Logger(
                    Standardiser(
                        FactoryPool(*check_pointed_drones, factory=drone_factory),
                        minimum=cpu_cores,
                        granularity=cpu_cores,
                    ),
                    name=f"{site.name.lower()}_{machine_type.lower()}",
                )
            )
        composites.append(
            Standardiser(
                WeightedComposite(*site_composites, weight="utilisation"),
                maximum=site.quota if site.quota >= 0 else inf,
            )
        )

    return WeightedComposite(*composites, weight="utilisation")