Skip to content

Commit

Permalink
Merge pull request #101 from VukManojlovic/CTX-5033
Browse files Browse the repository at this point in the history
CTX-5033: Allow integers instead of MetricType enum as type arguments for Metric.create
  • Loading branch information
igorperic17 authored Dec 5, 2023
2 parents 3370a1b + 289c897 commit 55a6e9b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions coretex/entities/task_run/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from typing import Dict, List, Optional
from typing import Dict, List, Optional, Union
from typing_extensions import Self

from .metric_type import MetricType
Expand Down Expand Up @@ -44,9 +44,9 @@ def create(
cls,
name: str,
xLabel: str,
xType: MetricType,
xType: Union[MetricType, int],
yLabel: str,
yType: MetricType,
yType: Union[MetricType, int],
xRange: Optional[List[float]] = None,
yRange: Optional[List[float]] = None
) -> Self:
Expand All @@ -56,18 +56,24 @@ def create(
name of Metric
xLabel : str
label of x axis which will be displayed
xType : MetricType
xType : Union[MetricType, int]
type of x axis which will be displayed
yLabel : str
label of y axis which will be displayed
yType : MetricType
yType : Union[MetricType, int]
type of y axis which will be displayed
xRange : Optional[List[float]]
range in which values will be displayed for x axis
yRange : Optional[List[float]]
range in which values will be displayed for y axis
"""

if isinstance(xType, int):
xType = MetricType(xType)

if isinstance(yType, int):
yType = MetricType(yType)

obj = cls()

obj.name = name
Expand Down

0 comments on commit 55a6e9b

Please sign in to comment.