Skip to content

Commit

Permalink
fix: Rename parameters names in extract_file_names action, Remove cod…
Browse files Browse the repository at this point in the history
…e related to influxdb 1.8
  • Loading branch information
roda82 committed Apr 23, 2024
1 parent 1a76d29 commit e28b364
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
33 changes: 1 addition & 32 deletions src/powerapi/cli/common_cli_parsing_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import sys

from powerapi.cli.parsing_manager import RootConfigParsingManager, SubgroupConfigParsingManager
from powerapi.cli.config_parser import store_true
from powerapi.cli.config_parser import store_true, extract_file_names

Check warning on line 33 in src/powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

src/powerapi/cli/common_cli_parsing_manager.py#L33

Added line #L33 was not covered by tests
from powerapi.cli.config_parser import MissingValueException
from powerapi.database.prometheus_db import DEFAULT_METRIC_DESCRIPTION, DEFAULT_MODEL_VALUE, DEFAULT_PUSHER_NAME, \
DEFAULT_ADDRESS
Expand All @@ -45,14 +45,6 @@
TAGS_ARGUMENT_HELP_TEXT = 'specify report tags'


def extract_file_names(arg, val, args, acc):
"""
action used to convert string from --files parameter into a list of file name
"""
acc[arg] = val.split(",")
return args, acc


class CommonCLIParsingManager(RootConfigParsingManager):
"""
PowerAPI basic config parser
Expand Down Expand Up @@ -307,29 +299,6 @@ def __init__(self):
subgroup_parser=subparser_csv_output
)

subparser_influx_output = SubgroupConfigParsingManager("influxdb")
subparser_influx_output.add_argument("u", "uri", help_text="specify InfluxDB uri")
subparser_influx_output.add_argument("t", "tags", help_text=TAGS_ARGUMENT_HELP_TEXT)
subparser_influx_output.add_argument(
"d", "db", help_text="specify InfluxDB database name"
)
subparser_influx_output.add_argument(
"p", "port", help_text="specify InfluxDB connection port", argument_type=int
)
subparser_influx_output.add_argument(
"m",
"model",
help_text="specify data type that will be stored in the database",
default_value="PowerReport",
)
subparser_influx_output.add_argument(
"n", "name", help_text="specify pusher name", default_value="pusher_influxdb"
)
self.add_subgroup_parser(
subgroup_name="output",
subgroup_parser=subparser_influx_output
)

subparser_opentsdb_output = SubgroupConfigParsingManager("opentsdb")
subparser_opentsdb_output.add_argument("u", "uri", help_text="specify openTSDB host")
subparser_opentsdb_output.add_argument(
Expand Down
8 changes: 8 additions & 0 deletions src/powerapi/cli/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def store_true(argument_name: str, configuration: dict, val: Any = None, args: l
return args, configuration


def extract_file_names(argument_name: str, val: Any, configuration: dict, args: list = None):
"""
Action used to convert string from --files parameter into a list of file name
"""
configuration[argument_name] = val.split(",")
return args, configuration

Check warning on line 71 in src/powerapi/cli/config_parser.py

View check run for this annotation

Codecov / codecov/patch

src/powerapi/cli/config_parser.py#L70-L71

Added lines #L70 - L71 were not covered by tests


class ConfigurationArgument:
"""
Argument provided by a formula configuration.
Expand Down
5 changes: 2 additions & 3 deletions src/powerapi/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,14 @@ class NotAllowedArgumentValueException(PowerAPIException):
"""


class FileDoesNotExistException(PowerAPIException):
class FileDoesNotExistException(PowerAPIExceptionWithMessage):
"""
This exception happens when the configuration define a input file that does not exist or is not accessible
"""

def __init__(self, file_name: str):
PowerAPIException.__init__(self)
PowerAPIExceptionWithMessage.__init__(self, "The File " + file_name + " does not exist or is not accessible")
self.file_name = file_name
self.msg = "The File " + self.file_name + " does not exist or is not accessible"


class SameLengthArgumentNamesException(ParserException):
Expand Down

0 comments on commit e28b364

Please sign in to comment.