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

166 add functionality to upload log text report files to google drive #170

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nguzinski
Copy link
Collaborator

#166
allows for automatic uploading of log files to Google Drive

this was added incase Google Cloud is unwanted/unavailable/ to allow for easier use of other storage devices

Built out from the previously created abstract storage service class, locks the thread during upload, creates the text file, the meta data for the upload, and uploads using the key.json.
Further, there is built-in testing if the gd_storage_service.py is ran as main.

Copy link
Collaborator

@Damerson1 Damerson1 left a comment

Choose a reason for hiding this comment

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

The code runs as expected. The test also shows if the file is uploaded or not. You may consider checking if the folder_id actually exists before attempting to use it. Example: If folder_id do this else create folder_id. It's just a small check in case the folder doesn't exist, the code will have a way to verify that's the case or possible handle it. Otherwise, the code runs as expected.

Copy link
Member

@mohamdlog mohamdlog left a comment

Choose a reason for hiding this comment

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

I had to modify a few things to get the project running (see my reviews). Uploading worked afterward. However, your code does not use real folders. Instead, it employs a pseudo-hierarchy:

Screenshot 2024-11-12 130301

Google Drive, unlike Google Cloud Storage, does support creating actual folders.

key.json
backend/key.json
Copy link
Member

Choose a reason for hiding this comment

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

You don’t need to add this to prevent pushing the key.json file, as it was already included in the .gitignore on the line above.

@@ -1,4 +1,5 @@
from PythonClient.multirotor.storage.abstract.storage_service import StorageServiceInterface
from abstract.storage_service import StorageServiceInterface
Copy link
Member

Choose a reason for hiding this comment

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

If you want to use relative imports, you just need to use a single period (.), which refers to the current package.

@@ -18,6 +19,47 @@ def __init__(self, folder_id='1zZ06TaCzqdPJlQ9Uc4VgJaawBZm3eTSS'):
"""
SCOPES = ['https://www.googleapis.com/auth/drive']
self.credentials = service_account.Credentials.from_service_account_file(
'key.json', scopes=SCOPES)
'backend/key.json', scopes=SCOPES)
Copy link
Member

Choose a reason for hiding this comment

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

The previous implementation was already trying to find key.json in the backend directory. Your implementation causes an error: FileNotFoundError: [Errno 2] No such file or directory: 'backend/key.json'.

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.

Add Functionality to Upload Log Text Report Files to Google Drive
3 participants