Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue313/correction csv source #314

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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 @@
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