From d3fadf9882801d012fba24b93fb8b73de08dbeb6 Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 18:15:52 -0400 Subject: [PATCH 01/13] create argument_types.py and began populating with parameters --- src/argument_types.py | 124 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/argument_types.py diff --git a/src/argument_types.py b/src/argument_types.py new file mode 100644 index 0000000..6baa0dd --- /dev/null +++ b/src/argument_types.py @@ -0,0 +1,124 @@ +# arguments.py +from typing import Dict, Literal + +from pydantic import BaseModel, Field + + +class Arguments(BaseModel): + lat: float + long: float + city: str + show_wave: bool = True + show_large_wave: bool = False + show_uv: bool = True + show_height: bool = True + show_direction: bool = True + show_period: bool = True + show_city: bool = True + show_date: bool = True + show_air_temp: bool = False + show_wind_speed: bool = False + show_wind_direction: bool = False + json_output: bool = False + show_rain_sum: bool = False + show_precipitation_prob: bool = False + unit: Literal["imperial", "metric"] = "imperial" + decimal: int = Field(default=1, ge=0) + forecast_days: int = Field(default=0, ge=0, le=7) + color: str = "blue" + gpt: bool = False + + +class ArgumentMappings(BaseModel): + show_wave: bool = Field( + default=True, + description="Show wave information", + aliases=["sw", "hide_wave", "hw"] + ) + show_large_wave: bool = Field( + default=False, + description="Show large wave information", + aliases=["slw"] + ) + show_uv: bool = Field( + default=True, + description="Show UV information", + aliases=["suv", "hide_uv", "huv"] + ) + show_height: bool = Field( + default=True, + description="Show wave height information", + aliases=["sh", "hide_height", "hh"] + ) + show_direction: bool = Field( + default=True, + description="Show wave direction information", + aliases=["sd", "hide_direction", "hdir"] + ) + show_period: bool = Field( + default=True, + description="Show wave period information", + aliases=["sp", "hide_period", "hp"] + ) + show_city: bool = Field( + default=True, + description="Show city information", + aliases=["sc", "hide_location", "hl"] + ) + show_date: bool = Field( + default=True, + description="Show date information", + aliases=["sdate", "hide_date", "hdate"] + ) + unit: Literal["imperial", "metric"] = Field( + default="imperial", + description="Set unit system", + aliases=["m", "metric"] + ) + json_output: bool = Field( + default=False, + description="Enable JSON output", + aliases=["j", "json"] + ) + gpt: bool = Field( + default=False, + description="Enable GPT functionality", + aliases=["g"] + ) + show_air_temp: bool = Field( + default=False, + description="Show air temperature", + aliases=["sat"] + ) + show_wind_speed: bool = Field( + default=False, + description="Show wind speed", + aliases=["sws"] + ) + show_wind_direction: bool = Field( + default=False, + description="Show wind direction", + aliases=["swd"] + ) + show_rain_sum: bool = Field( + default=False, + description="Show rain sum", + aliases=["srs"] + ) + show_precipitation_prob: bool = Field( + default=False, + description="Show precipitation probability", + aliases=["spp"] + ) + + @classmethod + def generate_mappings(cls) -> Dict[str, str]: + mappings = {} + for field_name, field in cls.model_fields.items(): + mappings[field_name] = field_name + for alias in field.alias_priority or []: + mappings[alias] = field_name + return mappings + + class Config: + allow_population_by_field_name = True From 3fbc3b8344cff5d72aa15c0b90b4c2726155c0a1 Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 18:55:44 -0400 Subject: [PATCH 02/13] add map for arguments --- src/argument_types.py | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/argument_types.py b/src/argument_types.py index 6baa0dd..710c8fd 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -1,10 +1,13 @@ # arguments.py -from typing import Dict, Literal +from typing import Literal from pydantic import BaseModel, Field class Arguments(BaseModel): + """ + Define arguments + """ lat: float long: float city: str @@ -30,95 +33,92 @@ class Arguments(BaseModel): class ArgumentMappings(BaseModel): + """ + Class for argument mappings with multiple aliases. + """ show_wave: bool = Field( default=True, description="Show wave information", - aliases=["sw", "hide_wave", "hw"] ) show_large_wave: bool = Field( default=False, description="Show large wave information", - aliases=["slw"] ) show_uv: bool = Field( default=True, description="Show UV information", - aliases=["suv", "hide_uv", "huv"] ) show_height: bool = Field( default=True, description="Show wave height information", - aliases=["sh", "hide_height", "hh"] ) show_direction: bool = Field( default=True, description="Show wave direction information", - aliases=["sd", "hide_direction", "hdir"] ) show_period: bool = Field( default=True, description="Show wave period information", - aliases=["sp", "hide_period", "hp"] ) show_city: bool = Field( default=True, description="Show city information", - aliases=["sc", "hide_location", "hl"] ) show_date: bool = Field( default=True, description="Show date information", - aliases=["sdate", "hide_date", "hdate"] ) unit: Literal["imperial", "metric"] = Field( default="imperial", description="Set unit system", - aliases=["m", "metric"] ) json_output: bool = Field( default=False, description="Enable JSON output", - aliases=["j", "json"] ) gpt: bool = Field( default=False, description="Enable GPT functionality", - aliases=["g"] ) show_air_temp: bool = Field( default=False, description="Show air temperature", - aliases=["sat"] ) show_wind_speed: bool = Field( default=False, description="Show wind speed", - aliases=["sws"] ) show_wind_direction: bool = Field( default=False, description="Show wind direction", - aliases=["swd"] ) show_rain_sum: bool = Field( default=False, description="Show rain sum", - aliases=["srs"] ) show_precipitation_prob: bool = Field( default=False, description="Show precipitation probability", - aliases=["spp"] ) - @classmethod - def generate_mappings(cls) -> Dict[str, str]: - mappings = {} - for field_name, field in cls.model_fields.items(): - mappings[field_name] = field_name - for alias in field.alias_priority or []: - mappings[alias] = field_name - return mappings + alias_map = { + "show_wave": ["sw", "hide_wave", "hw"], + "show_large_wave": ["slw"], + "show_uv": ["suv", "hide_uv", "huv"], + "show_height": ["sh", "hide_height", "hh"], + "show_direction": ["sd", "hide_direction", "hdir"], + "show_period": ["sp", "hide_period", "hp"], + "show_city": ["sc", "hide_location", "hl"], + "show_date": ["sdate", "hide_date", "hdate"], + "unit": ["m", "metric"], + "json_output": ["j", "json"], + "gpt": ["g"], + "show_air_temp": ["sat"], + "show_wind_speed": ["sws"], + "show_wind_direction": ["swd"], + "show_rain_sum": ["srs"], + "show_precipitation_prob": ["spp"] + } class Config: allow_population_by_field_name = True From b26433a6e7515f82bb5a6784b08a7c99ad29ba3e Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 18:59:26 -0400 Subject: [PATCH 03/13] add methods to generate the mappings --- src/argument_types.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/argument_types.py b/src/argument_types.py index 710c8fd..2866b4f 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -120,5 +120,27 @@ class ArgumentMappings(BaseModel): "show_precipitation_prob": ["spp"] } + @classmethod + def generate_mappings(cls) -> dict[str, str]: + """ + Flatten the alias map to create a mapping from each alias to the field + name + """"" + mappings = {} + for field_name, aliases in cls.alias_map.items(): + for alias in aliases: + mappings[alias] = field_name + return mappings + + @classmethod + def parse_input(cls, data: dict) -> dict: + alias_to_field_map = cls.generate_mappings() + remapped_data = {} + for key, value in data.items(): + field_name = alias_to_field_map.get(key, key) + remapped_data[field_name] = value + + return remapped_data + class Config: allow_population_by_field_name = True From 2438757862dfc18c0db1f09a21774df1615d8f6d Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 19:02:18 -0400 Subject: [PATCH 04/13] move set_output_values to argument_types class --- src/argument_types.py | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/argument_types.py b/src/argument_types.py index 2866b4f..5a4e092 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -142,5 +142,58 @@ def parse_input(cls, data: dict) -> dict: return remapped_data + @classmethod + def set_output_values(cls, args, arguments_dictionary: dict) -> dict: + """ + Takes a list of command line arguments(args) + and sets the appropritate values in the + arguments_dictionary(show_wave = 1, etc). + Returns the arguments_dictionary dict with the updated CLI args + """ + # map of arguments to dictionary keys & values + mappings = { + "hide_wave": ("show_wave", 0), + "hw": ("show_wave", 0), + "show_large_wave": ("show_large_wave", 1), + "slw": ("show_large_wave", 1), + "hide_uv": ("show_uv", 0), + "huv": ("show_uv", 0), + "hide_height": ("show_height", 0), + "hh": ("show_height", 0), + "hide_direction": ("show_direction", 0), + "hdir": ("show_direction", 0), + "hide_period": ("show_period", 0), + "hp": ("show_period", 0), + "hide_location": ("show_city", 0), + "hl": ("show_city", 0), + "hide_date": ("show_date", 0), + "hdate": ("show_date", 0), + "metric": ("unit", "metric"), + "m": ("unit", "metric"), + "json": ("json_output", 1), + "j": ("json_output", 1), + "gpt": ("gpt", 1), + "g": ("gpt", 1), + "show_air_temp": ("show_air_temp", 1), + "sat": ("show_air_temp", 1), + "show_wind_speed": ("show_wind_speed", 1), + "sws": ("show_wind_speed", 1), + "show_wind_direction": ("show_wind_direction", 1), + "swd": ("show_wind_direction", 1), + "show_rain_sum": ("show_rain_sum", 1), + "srs": ("show_rain_sum", 1), + "show_precipitation_prob": ("show_precipitation_prob", 1), + "spp": ("show_precipitation_prob", 1), + } + # Update arguments_dictionary based on the cli arguments in args + # Ex: If "hide_uv" in args, + # "show_uv" will be set to 0 in arguments_dictionary + for arg in args: + if arg in mappings: + key, value = mappings[arg] + arguments_dictionary[key] = value + + return arguments_dictionary + class Config: allow_population_by_field_name = True From 6fcff8796e2bb79fa54edd5cc947e6b2b7cf6f94 Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 19:32:25 -0400 Subject: [PATCH 05/13] began using argument_types into main --- src/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cli.py b/src/cli.py index 3f2a12b..ddde80b 100644 --- a/src/cli.py +++ b/src/cli.py @@ -5,6 +5,7 @@ import sys from src import api, helper, settings +from src.argument_types import ArgumentMappings, Arguments # Load environment variables from .env file env = settings.GPTSettings() @@ -25,8 +26,13 @@ def run(lat=0, long=0, args=None): else: args = helper.seperate_args(args) + parsed_arguments = ArgumentMappings.parse(args) + + arguments = Arguments(**parsed_arguments) + # return coordinates, lat, long, city location = api.seperate_args_and_get_location(args) + print(arguments.city) # Set location returns: city, lat, long set_location = helper.set_location(location) From 3d3a7a39e86419ed3a61b29397108389420af314 Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 19:54:33 -0400 Subject: [PATCH 06/13] fixed imports and populate_by_name parameter --- src/argument_types.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/argument_types.py b/src/argument_types.py index 5a4e092..09068ed 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -1,5 +1,4 @@ -# arguments.py -from typing import Literal +from typing import ClassVar, Literal from pydantic import BaseModel, Field @@ -87,7 +86,7 @@ class ArgumentMappings(BaseModel): show_wind_speed: bool = Field( default=False, description="Show wind speed", - ) + ) show_wind_direction: bool = Field( default=False, description="Show wind direction", @@ -101,7 +100,7 @@ class ArgumentMappings(BaseModel): description="Show precipitation probability", ) - alias_map = { + alias_map: ClassVar[dict[str, list[str]]] = { "show_wave": ["sw", "hide_wave", "hw"], "show_large_wave": ["slw"], "show_uv": ["suv", "hide_uv", "huv"], @@ -125,7 +124,7 @@ def generate_mappings(cls) -> dict[str, str]: """ Flatten the alias map to create a mapping from each alias to the field name - """"" + """ mappings = {} for field_name, aliases in cls.alias_map.items(): for alias in aliases: @@ -145,11 +144,11 @@ def parse_input(cls, data: dict) -> dict: @classmethod def set_output_values(cls, args, arguments_dictionary: dict) -> dict: """ - Takes a list of command line arguments(args) - and sets the appropritate values in the - arguments_dictionary(show_wave = 1, etc). - Returns the arguments_dictionary dict with the updated CLI args - """ + Takes a list of command line arguments(args) + and sets the appropriate values in the + arguments_dictionary(show_wave = 1, etc). + Returns the arguments_dictionary dict with the updated CLI args + """ # map of arguments to dictionary keys & values mappings = { "hide_wave": ("show_wave", 0), @@ -196,4 +195,4 @@ def set_output_values(cls, args, arguments_dictionary: dict) -> dict: return arguments_dictionary class Config: - allow_population_by_field_name = True + populate_by_name = True From 39c5c39b4f70d34dd1233aafac9f08e58a21af57 Mon Sep 17 00:00:00 2001 From: avkoll Date: Wed, 7 Aug 2024 20:28:26 -0400 Subject: [PATCH 07/13] class init works and methods work, comments at bottom are for testing --- src/argument_types.py | 109 ++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/src/argument_types.py b/src/argument_types.py index 09068ed..e4d8169 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -1,3 +1,4 @@ +import json from typing import ClassVar, Literal from pydantic import BaseModel, Field @@ -7,9 +8,9 @@ class Arguments(BaseModel): """ Define arguments """ - lat: float - long: float - city: str + lat: float = 0.0 + long: float = 0.0 + city: str = "pleasure_point" show_wave: bool = True show_large_wave: bool = False show_uv: bool = True @@ -151,42 +152,42 @@ def set_output_values(cls, args, arguments_dictionary: dict) -> dict: """ # map of arguments to dictionary keys & values mappings = { - "hide_wave": ("show_wave", 0), - "hw": ("show_wave", 0), - "show_large_wave": ("show_large_wave", 1), - "slw": ("show_large_wave", 1), - "hide_uv": ("show_uv", 0), - "huv": ("show_uv", 0), - "hide_height": ("show_height", 0), - "hh": ("show_height", 0), - "hide_direction": ("show_direction", 0), - "hdir": ("show_direction", 0), - "hide_period": ("show_period", 0), - "hp": ("show_period", 0), - "hide_location": ("show_city", 0), - "hl": ("show_city", 0), - "hide_date": ("show_date", 0), - "hdate": ("show_date", 0), + "hide_wave": ("show_wave", False), + "hw": ("show_wave", False), + "show_large_wave": ("show_large_wave", True), + "slw": ("show_large_wave", True), + "hide_uv": ("show_uv", False), + "huv": ("show_uv", False), + "hide_height": ("show_height", False), + "hh": ("show_height", False), + "hide_direction": ("show_direction", False), + "hdir": ("show_direction", False), + "hide_period": ("show_period", False), + "hp": ("show_period", False), + "hide_location": ("show_city", False), + "hl": ("show_city", False), + "hide_date": ("show_date", False), + "hdate": ("show_date", False), "metric": ("unit", "metric"), "m": ("unit", "metric"), - "json": ("json_output", 1), - "j": ("json_output", 1), - "gpt": ("gpt", 1), - "g": ("gpt", 1), - "show_air_temp": ("show_air_temp", 1), - "sat": ("show_air_temp", 1), - "show_wind_speed": ("show_wind_speed", 1), - "sws": ("show_wind_speed", 1), - "show_wind_direction": ("show_wind_direction", 1), - "swd": ("show_wind_direction", 1), - "show_rain_sum": ("show_rain_sum", 1), - "srs": ("show_rain_sum", 1), - "show_precipitation_prob": ("show_precipitation_prob", 1), - "spp": ("show_precipitation_prob", 1), + "json": ("json_output", True), + "j": ("json_output", True), + "gpt": ("gpt", True), + "g": ("gpt", True), + "show_air_temp": ("show_air_temp", True), + "sat": ("show_air_temp", True), + "show_wind_speed": ("show_wind_speed", True), + "sws": ("show_wind_speed", True), + "show_wind_direction": ("show_wind_direction", True), + "swd": ("show_wind_direction", True), + "show_rain_sum": ("show_rain_sum", True), + "srs": ("show_rain_sum", True), + "show_precipitation_prob": ("show_precipitation_prob", True), + "spp": ("show_precipitation_prob", True), } # Update arguments_dictionary based on the cli arguments in args # Ex: If "hide_uv" in args, - # "show_uv" will be set to 0 in arguments_dictionary + # "show_uv" will be set to False in arguments_dictionary for arg in args: if arg in mappings: key, value = mappings[arg] @@ -194,5 +195,41 @@ def set_output_values(cls, args, arguments_dictionary: dict) -> dict: return arguments_dictionary - class Config: - populate_by_name = True +""" +def main(): + # Sample input data + input_data = { + "lat": 34.05, + "long": -118.25, + + } + + # Create an Arguments instance using the parsed input data + parsed_input = ArgumentMappings.parse_input(input_data) + + # Create an instance of Arguments using only valid fields + arguments = Arguments(**parsed_input) + + # Print the arguments to verify they are parsed correctly + print("Arguments:") + print(json.dumps(arguments.model_dump(), indent=4)) # Use json.dumps with model_dump + + # Example of using the set_output_values method + args = ["hide_wave", "json", "g", "sws", "m"] + arguments_dict = arguments.dict() + updated_arguments_dict = ArgumentMappings.set_output_values(args, arguments_dict) + + # Print the updated arguments dictionary + print("\nUpdated Arguments Dictionary:") + print(json.dumps(updated_arguments_dict, indent=4)) # Use json.dumps for printing dictionaries + + +if __name__ == "__main__": + main() +""" + +""" +This is a lot more complicated than I thought, +So far the class and methods work without errors but I need to impleement them +into cli.py with the correct data and whatnot +""" \ No newline at end of file From 3bb50543fb4d852fe34bd37de2b6be4f02738285 Mon Sep 17 00:00:00 2001 From: avkoll Date: Thu, 8 Aug 2024 11:00:12 -0400 Subject: [PATCH 08/13] added mappings for location --- src/argument_types.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/argument_types.py b/src/argument_types.py index e4d8169..7683b15 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -36,6 +36,10 @@ class ArgumentMappings(BaseModel): """ Class for argument mappings with multiple aliases. """ + city: str = Field( + default="pleasure_point", + description="Name of the city you want weather data from", + ) show_wave: bool = Field( default=True, description="Show wave information", @@ -102,6 +106,7 @@ class ArgumentMappings(BaseModel): ) alias_map: ClassVar[dict[str, list[str]]] = { + "city": ["loc", "location"], "show_wave": ["sw", "hide_wave", "hw"], "show_large_wave": ["slw"], "show_uv": ["suv", "hide_uv", "huv"], @@ -142,6 +147,10 @@ def parse_input(cls, data: dict) -> dict: return remapped_data + """ + TODO: write method to set location and update the dictionary + """ + @classmethod def set_output_values(cls, args, arguments_dictionary: dict) -> dict: """ From 51cf1a7c7b3c05d4d0e9b1f39e98fa31893e84d3 Mon Sep 17 00:00:00 2001 From: avkoll Date: Thu, 8 Aug 2024 11:01:56 -0400 Subject: [PATCH 09/13] removed comments at bottom of argument_types.py --- src/argument_types.py | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/src/argument_types.py b/src/argument_types.py index 7683b15..21fc750 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -203,42 +203,3 @@ def set_output_values(cls, args, arguments_dictionary: dict) -> dict: arguments_dictionary[key] = value return arguments_dictionary - -""" -def main(): - # Sample input data - input_data = { - "lat": 34.05, - "long": -118.25, - - } - - # Create an Arguments instance using the parsed input data - parsed_input = ArgumentMappings.parse_input(input_data) - - # Create an instance of Arguments using only valid fields - arguments = Arguments(**parsed_input) - - # Print the arguments to verify they are parsed correctly - print("Arguments:") - print(json.dumps(arguments.model_dump(), indent=4)) # Use json.dumps with model_dump - - # Example of using the set_output_values method - args = ["hide_wave", "json", "g", "sws", "m"] - arguments_dict = arguments.dict() - updated_arguments_dict = ArgumentMappings.set_output_values(args, arguments_dict) - - # Print the updated arguments dictionary - print("\nUpdated Arguments Dictionary:") - print(json.dumps(updated_arguments_dict, indent=4)) # Use json.dumps for printing dictionaries - - -if __name__ == "__main__": - main() -""" - -""" -This is a lot more complicated than I thought, -So far the class and methods work without errors but I need to impleement them -into cli.py with the correct data and whatnot -""" \ No newline at end of file From a10e22233887f21a113cc755f19fe83f830513e2 Mon Sep 17 00:00:00 2001 From: avkoll Date: Thu, 8 Aug 2024 11:02:23 -0400 Subject: [PATCH 10/13] removed unused import --- src/argument_types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/argument_types.py b/src/argument_types.py index 21fc750..08eaf82 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -1,4 +1,3 @@ -import json from typing import ClassVar, Literal from pydantic import BaseModel, Field From 5d990c6d45662f05b4df3c07613e531fad5ba469 Mon Sep 17 00:00:00 2001 From: avkoll Date: Thu, 8 Aug 2024 11:15:13 -0400 Subject: [PATCH 11/13] began converting old cli.py to use new classes --- src/cli.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/cli.py b/src/cli.py index ddde80b..a198c9d 100644 --- a/src/cli.py +++ b/src/cli.py @@ -2,10 +2,11 @@ Main module """ +import json import sys from src import api, helper, settings -from src.argument_types import ArgumentMappings, Arguments +from argument_types import Arguments, ArgumentMappings # Load environment variables from .env file env = settings.GPTSettings() @@ -26,13 +27,31 @@ def run(lat=0, long=0, args=None): else: args = helper.seperate_args(args) - parsed_arguments = ArgumentMappings.parse(args) + # Begin my whacked implementation tests + default_arguments = Arguments() + print(json.dumps(default_arguments.model_dump(), indent=4)) - arguments = Arguments(**parsed_arguments) + # parse inputs + parsed_input = ArgumentMappings.parse_input({"lat": lat, "long": long}) + updated_arguments = default_arguments.model_copy(update=parsed_input) + + # update arguments with inputs + arguments_dict = updated_arguments.model_dump() + updated_arguments_dict = ArgumentMappings.set_output_values(args, arguments_dict) + arguments = updated_arguments.model_copy(update=updated_arguments_dict) + + print("Updated arguments: ") + print(json.dumps(updated_arguments.model_dump(), indent=4)) + + for key, value in updated_arguments: + if value is False: + print("false") + else: + print(key) + # End the test section # return coordinates, lat, long, city location = api.seperate_args_and_get_location(args) - print(arguments.city) # Set location returns: city, lat, long set_location = helper.set_location(location) From 3e8cac727f0c344dbcaf5a2a7a8dbd78f6263da5 Mon Sep 17 00:00:00 2001 From: avkoll Date: Fri, 9 Aug 2024 10:06:46 -0400 Subject: [PATCH 12/13] remove class use in cli.py --- src/cli.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/cli.py b/src/cli.py index a198c9d..b276e6b 100644 --- a/src/cli.py +++ b/src/cli.py @@ -27,29 +27,6 @@ def run(lat=0, long=0, args=None): else: args = helper.seperate_args(args) - # Begin my whacked implementation tests - default_arguments = Arguments() - print(json.dumps(default_arguments.model_dump(), indent=4)) - - # parse inputs - parsed_input = ArgumentMappings.parse_input({"lat": lat, "long": long}) - updated_arguments = default_arguments.model_copy(update=parsed_input) - - # update arguments with inputs - arguments_dict = updated_arguments.model_dump() - updated_arguments_dict = ArgumentMappings.set_output_values(args, arguments_dict) - arguments = updated_arguments.model_copy(update=updated_arguments_dict) - - print("Updated arguments: ") - print(json.dumps(updated_arguments.model_dump(), indent=4)) - - for key, value in updated_arguments: - if value is False: - print("false") - else: - print(key) - # End the test section - # return coordinates, lat, long, city location = api.seperate_args_and_get_location(args) From 849e16d8ef804f42be622bc8319de91c8561f2c7 Mon Sep 17 00:00:00 2001 From: avkoll Date: Fri, 9 Aug 2024 10:13:31 -0400 Subject: [PATCH 13/13] ran pre commit tests --- src/argument_types.py | 4 +++- src/cli.py | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/argument_types.py b/src/argument_types.py index 08eaf82..7c31772 100644 --- a/src/argument_types.py +++ b/src/argument_types.py @@ -7,6 +7,7 @@ class Arguments(BaseModel): """ Define arguments """ + lat: float = 0.0 long: float = 0.0 city: str = "pleasure_point" @@ -35,6 +36,7 @@ class ArgumentMappings(BaseModel): """ Class for argument mappings with multiple aliases. """ + city: str = Field( default="pleasure_point", description="Name of the city you want weather data from", @@ -121,7 +123,7 @@ class ArgumentMappings(BaseModel): "show_wind_speed": ["sws"], "show_wind_direction": ["swd"], "show_rain_sum": ["srs"], - "show_precipitation_prob": ["spp"] + "show_precipitation_prob": ["spp"], } @classmethod diff --git a/src/cli.py b/src/cli.py index b276e6b..3f2a12b 100644 --- a/src/cli.py +++ b/src/cli.py @@ -2,11 +2,9 @@ Main module """ -import json import sys from src import api, helper, settings -from argument_types import Arguments, ArgumentMappings # Load environment variables from .env file env = settings.GPTSettings()