Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.0 kB
2
Indexable
Never
I have this code in A.py
class __BasePerfWorkflowService:
    """Base class for Perf workflows"""

    def __init__(
        self,
        name: str,
        workflow_config: dict,
        user_config: dict,
        workflow_prefix: str = None,
        **kwargs,
    ):
        """
        Initialize base workflow
        Params:
        :workflow_params, dict, Workflow params.
        """
        self.__engine = None
        self.__workflow_type = None
        self.__rdsbms_manager = None
        self.__perf_manager = None
        self.__parent_workflow_id = None
        self.__internal_workflow_id = None
        self.__pas_workflow_type = None
        self.__workflow_config = None
        self.__workflow_params = None

        # Presets
        self.__name = name
        self.__workflow_prefix = workflow_prefix
        self.__user_config = copy.deepcopy(user_config)

        self._set_workflow_params(workflow_config)

        self.__db_instance_size = get_instance_size(self.workflow_config["config"])
        self.__workflow_user = kwargs.get("workflow_user", None)

    @property
    def internal_workflow_id(self):
        if self.__internal_workflow_id:
            return self.__internal_workflow_id

        if not self.engine:
            return
        prefix = f"{self.__workflow_prefix}-" if self.__workflow_prefix else ""
        self.__internal_workflow_id = prefix + self.engine.strip() + f"-{uuid.uuid4().hex}"
        return self.__internal_workflow_id

    @property
    def parent_workflow_id(self):
        """ """
        # TODO : This is a temporary fix.
        # Need to add `workflow` attr.
        return self.__parent_workflow_id

    @property
    def pas_workflow_type(self):
        if not self.__pas_workflow_type:
            if (
                "config" in self.workflow_config
                and "pasWorkflowType" in self.workflow_config["config"]
                and self.workflow_config["config"]["pasWorkflowType"]
                in [workflow_type.value for workflow_type in PASWorkflowType]
            ):
                self.__pas_workflow_type = self.workflow_config["config"]["pasWorkflowType"]

        return self.__pas_workflow_type

    @property
    def workflow_config(self):
        """ """
        return self.__workflow_config

    @property
    def user_config(self):
        return self.__user_config

    @property
    def name(self):
        """ """
        return self.__name

    @property
    def rdsbms_manager(self):
        """BMS Workflow Manager"""
        if not self.__rdsbms_manager:
            self.__rdsbms_manager = get_rdsbms_workflow_manager()

        return self.__rdsbms_manager

    @property
    def workflow_params(self):
        """ """
        return self.__workflow_params

    @property
    def workflow_type(self):
        """ """
        return self.workflow_params.config.workflow_type

I want to use value obtained from  @property
    def workflow_params(self):
        """ """
        return self.__workflow_params
in different python file
Leave a Comment