Skip to content

Commit

Permalink
Consistent argument style (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
taral authored Nov 25, 2021
1 parent f498349 commit 9dea514
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
2 changes: 1 addition & 1 deletion exabel_data_sdk/scripts/csv_script_with_entity_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, argv: Sequence[str], description: str):
"Supports *.json and *.csv extensions only."
)
self.parser.add_argument(
"--entity_mapping_filename", required=False, type=str, help=help_text
"--entity-mapping-filename", required=False, type=str, help=help_text
)

def read_entity_mapping_file(
Expand Down
2 changes: 1 addition & 1 deletion exabel_data_sdk/scripts/get_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, argv: Sequence[str]):
help="The last date of the time series",
)
self.parser.add_argument(
"--known_time",
"--known-time",
required=False,
type=str,
help="The point-in-time to retrieve the time series at",
Expand Down
10 changes: 5 additions & 5 deletions exabel_data_sdk/scripts/load_entities_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LoadEntitiesFromCsv(CsvScript):
The CSV file should have a header line specifying the column names.
The command line argument --name_column specifies the column from which to read
The command line argument --name-column specifies the column from which to read
the entity names. The entity names are automatically normalized to create a valid
resource name for the entity.
Expand All @@ -30,28 +30,28 @@ class LoadEntitiesFromCsv(CsvScript):
def __init__(self, argv: Sequence[str], description: str):
super().__init__(argv, description)
self.parser.add_argument(
"--entity_type",
"--entity-type",
required=False,
type=str,
help="The type of the entities to be loaded. Must already exist in the data model. "
"If not specified, defaults to the same value as the name_column argument.",
)
self.parser.add_argument(
"--name_column",
"--name-column",
required=False,
type=str,
help="The column name for the entity name. "
"If not specified, defaults to the first column in the file.",
)
self.parser.add_argument(
"--display_name_column",
"--display-name-column",
required=False,
type=str,
help="The column name for the entity's display name. "
"If not specified, uses the entity name",
)
self.parser.add_argument(
"--description_column",
"--description-column",
required=False,
type=str,
help="The column name for the entity description. "
Expand Down
18 changes: 9 additions & 9 deletions exabel_data_sdk/scripts/load_relationships_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoadRelationshipsFromCsv(CsvScriptWithEntityMapping):
The CSV file should have a header line specifying the column names.
The command line arguments --entity_from_column and --entity_to_column specify the columns
The command line arguments --entity-from-column and --entity-to-column specify the columns
in which the related entities are given. The entity names are automatically normalized to
form the corresponding resource names (consistently with the load_entities_from_csv script).
Expand All @@ -32,34 +32,34 @@ class LoadRelationshipsFromCsv(CsvScriptWithEntityMapping):
Beyond Meat,Beyond Burger,Plant-based patties
which would be loaded by specifying:
--relationship_type my_namespace.HAS_PRODUCT
--entity_from_column brand
--entity_to_column product
--description_column description
--relationship-type my_namespace.HAS_PRODUCT
--entity-from-column brand
--entity-to-column product
--description-column description
"""

def __init__(self, argv: Sequence[str], description: str):
super().__init__(argv, description)
self.parser.add_argument(
"--relationship_type",
"--relationship-type",
required=True,
type=str,
help="The type of the relationships to be loaded. Created if it doesn't already exist.",
)
self.parser.add_argument(
"--entity_from_column",
"--entity-from-column",
required=True,
type=str,
help="The column name for the entity from which the relationship originates.",
)
self.parser.add_argument(
"--entity_to_column",
"--entity-to-column",
required=True,
type=str,
help="The column name for the entity name to which the relationship goes.",
)
self.parser.add_argument(
"--description_column",
"--description-column",
required=False,
type=str,
help="The column name for the relationship description. "
Expand Down
8 changes: 4 additions & 4 deletions exabel_data_sdk/scripts/load_time_series_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ def __init__(self, argv: Sequence[str]):
description = "Upload timeseries file."
super().__init__(argv, description)
self.parser.add_argument(
"--create_missing_signals",
"--create-missing-signals",
required=False,
action="store_true",
default=False,
help="Automatically create signals that are not already present in the API.",
)
self.parser.add_argument(
"--pit_current_time",
"--pit-current-time",
required=False,
action="store_true",
default=False,
help="Set the Known-Time of the uploaded data to be "
"the time at which it is inserted into the Exabel system.",
)
self.parser.add_argument(
"--pit_offset",
"--pit-offset",
required=False,
type=int,
choices=range(31),
metavar="[0-30]",
help="Set the Known-Time of the uploaded data to be the timestamp of each data point, "
"plus the specified number of days as an offset. For instance, if the data is "
"available to the user the day after, one would set --pit_offset 1",
"available to the user the day after, one would set --pit-offset 1",
)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
class TestCsvScriptWithEntitySearch(unittest.TestCase):
def test_read_entity_mapping_file_json(self):
args = common_args + [
"--entity_mapping_filename",
"--entity-mapping-filename",
"./exabel_data_sdk/tests/resources/data/entity_mapping.json",
]

Expand All @@ -39,7 +39,7 @@ def test_read_entity_mapping_file_json(self):

def test_read_entity_mapping_file_csv(self):
args = common_args + [
"--entity_mapping_filename",
"--entity-mapping-filename",
"./exabel_data_sdk/tests/resources/data/entity_mapping.csv",
]

Expand All @@ -53,7 +53,7 @@ def test_read_entity_mapping_file_csv(self):

def test_should_fail_read_entity_mapping_file_invalid_csv(self):
args = common_args + [
"--entity_mapping_filename",
"--entity-mapping-filename",
"./exabel_data_sdk/tests/resources/data/entity_mapping_invalid.csv",
]

Expand All @@ -68,7 +68,7 @@ def test_should_fail_read_entity_mapping_file_invalid_json(self):
]

for file in files:
args = common_args + ["--entity_mapping_filename", file]
args = common_args + ["--entity-mapping-filename", file]
loader = ConcreteCsvScriptWithEntitySearch(args, "Load")
with self.assertRaises(SystemExit):
loader.read_entity_mapping_file(loader.parse_arguments())
Expand All @@ -81,7 +81,7 @@ def test_should_fail_read_entity_mapping_file_invalid_extension(self):
]

for file in files:
args = common_args + ["--entity_mapping_filename", file]
args = common_args + ["--entity-mapping-filename", file]
loader = ConcreteCsvScriptWithEntitySearch(args, "Load")
with self.assertRaises(SystemExit):
loader.read_entity_mapping_file(loader.parse_arguments())
4 changes: 2 additions & 2 deletions exabel_data_sdk/tests/scripts/test_load_entities_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_read_file(self):
args = common_args + [
"--filename",
"./exabel_data_sdk/tests/resources/data/entities.csv",
"--description_col",
"--description-col",
"description",
]
client = load_test_data_from_csv(LoadEntitiesFromCsv, args)
Expand All @@ -42,7 +42,7 @@ def test_read_file_with_integer_identifier(self):
"--filename",
"./exabel_data_sdk/tests/resources/data/entities_with_integer_identifiers.csv",
]
extra_args = [[], ["--name_column", "brand"]]
extra_args = [[], ["--name-column", "brand"]]
expected_entities = [
Entity(name="entityTypes/brand/entities/test.0001", display_name="0001"),
Entity(name="entityTypes/brand/entities/test.0002", display_name="0002"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"acme",
"--api-key",
"123",
"--relationship_type",
"--relationship-type",
"PART_OF",
"--entity_to_column",
"--entity-to-column",
"brand",
]

Expand All @@ -23,9 +23,9 @@ def test_read_file(self):
args = common_args + [
"--filename",
"./exabel_data_sdk/tests/resources/data/relationships.csv",
"--entity_from_column",
"--entity-from-column",
"entity_from",
"--description_column",
"--description-column",
"description",
]
client = load_test_data_from_csv(LoadRelationshipsFromCsv, args)
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_read_file_with_integer_identifiers(self):
args = common_args + [
"--filename",
"./exabel_data_sdk/tests/resources/data/relationships_with_integer_identifiers.csv",
"--entity_from_column",
"--entity-from-column",
"company",
]
client = load_test_data_from_csv(LoadRelationshipsFromCsv, args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_read_file_use_header_for_signal(self):
"./exabel_data_sdk/tests/resources/data/timeseries.csv",
"--namespace",
"",
"--pit_current_time",
"--pit-current-time",
]

script = LoadTimeSeriesFromCsv(args)
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_read_file_with_multiple_signals(self):
"./exabel_data_sdk/tests/resources/data/timeseries_multiple_signals.csv",
"--namespace",
"acme",
"--pit_offset",
"--pit-offset",
"0",
]
script = LoadTimeSeriesFromCsv(args)
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_read_file_with_integer_identifiers(self):
"./exabel_data_sdk/tests/resources/data/timeseries_with_integer_identifiers.csv",
"--namespace",
"acme",
"--pit_offset",
"--pit-offset",
"30",
]

Expand Down

0 comments on commit 9dea514

Please sign in to comment.