Skip to content

79 refactor fetch and alert pull request#82

Open
montse-jara wants to merge 51 commits intodevfrom
79_refactor_fetch_and_alert
Open

79 refactor fetch and alert pull request#82
montse-jara wants to merge 51 commits intodevfrom
79_refactor_fetch_and_alert

Conversation

@montse-jara
Copy link
Copy Markdown
Collaborator

Refactored Fetch and Alert to use a new class get info which gets all the information from the configuration file. Pylint and flake8 errors fixed for get images, detect images, get info, and fetch and alert.

changed all attribute names in class configInfo
to be capitalized. Changed refences to CONFIG to
object config of the configInfo class. To access
class attibutes use config.'ATTRIBUTE_NAME'
…ile. Called parse_args in main and passed return value to configInfo to create config object. Also passed the return value to fetch and alert.
… argurment parser to main. This class now expects a config_path as a string when creating a ConfigInfo object.
… config_path in main to clarify the passing of objects vs. paths
…y pylint and flake8. Unable to resolve 2 import errors.
…changed detector in ConfigInfo to detector_model.
…fer model, detector model, and class_list using the passed config object.
… Unable to resolve some pylint import errors.
@kgarwoodsdzwa
Copy link
Copy Markdown
Member

We don't want to include the "logs" folder in this pr, it just contains dataframes that are generated when the program is run, and shouldnt be in this pr.

@kgarwoodsdzwa
Copy link
Copy Markdown
Member

youll also need to update the fetch_and_alert.yml to reflect the changes made to the config file. you made the changes in your copy of the yaml file, but the example fetch_and_alert.yml needs to be updated and pushed as well. make sure to not include any passwords or anything in the config file that gets pushed to github


# add path to camera traps repository instead using
# cougar traps yaml
sys.path.append(config.traps_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can actually remove this altogether- and from the config file. im realizing it was a legacy library needed before the recent animl update. so feel free to remove this line and remove camera traps repo path from the config as well.

try:
response = requests.get(call, headers={"X-User-Email": username,
"X-User-Token": auth_token},
timeout=10)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increase timeout to 20 seconds, my internet connection took longer than 10 seconds to make the first request so it looked like it was failing but increasing this timeout gave it enough time to make the request

info = json.loads(response.text)
return info

except requests.exceptions.ConnectionError as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have the attempts write to the log file. so that we can look back later and see failed connection attempts

print(f'Timeout Error {attempt + 1}: {e}')
time.sleep(15) # wait 15 seconds

raise Exception("Failed to connect after multiple attempts.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should keep this in for now- but i have an idea to make this better in a way that doesnt kill the program if it fails 5 retries. ill make a new issue so that we can merge this branch and then address that fix after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants