Skip to content

types

InputVariable dataclass

Class to generate code related input variable and it's default value

Parameters:

Name Type Description Default
variable_name

variable name

required
value

variable value

required
value_type

variable object type

required

Attributes: default_args: ex: a = 1 parser_body: ex: parser.add_argument('--a', default=1, type=int) parser_args: ex: a = args.a

Source code in lineapy/graph_reader/types.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@dataclass
class InputVariable:
    """
    Class to generate code related input variable and it's default value

    Parameters
    ----------
    variable_name:
        variable name
    value:
        variable value
    value_type:
        variable object type

    Attributes:
        default_args: ex: ``a = 1``
        parser_body: ex: ``parser.add_argument('--a', default=1, type=int)``
        parser_args: ex: ``a = args.a``

    """

    def __init__(self, variable_name, value, value_type) -> None:
        self.variable_name = variable_name
        self.value = value
        self.value_type = value_type.__name__
        self.default_args = f"{self.variable_name} = {repr(self.value)}"
        self.parser_body = f"parser.add_argument('--{self.variable_name}', type={self.value_type}, default={repr(self.value)})"
        self.parser_args = f"{self.variable_name} = args.{self.variable_name}"

Was this helpful?

Help us improve docs with your feedback!