Skip to content

Unstructured file metadata #447

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

Merged
merged 4 commits into from
Jun 18, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ google-cloud-aiplatform
google-cloud-bigquery==3.19.0
google-cloud-core==2.4.1
google-cloud-resource-manager==1.12.3
google-cloud-storage==2.16.0
google-cloud-storage
google-crc32c==1.5.0
google-resumable-media==2.7.0
googleapis-common-protos==1.63.0
Expand Down
24 changes: 13 additions & 11 deletions backend/src/document_sources/gcs_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from PyPDF2 import PdfReader
import io
from google.oauth2.credentials import Credentials
import time

def get_gcs_bucket_files_info(gcs_project_id, gcs_bucket_name, gcs_bucket_folder, creds):
storage_client = storage.Client(project=gcs_project_id, credentials=creds)
Expand Down Expand Up @@ -87,20 +88,21 @@ def upload_file_to_gcs(file_chunk, chunk_number, original_file_name, bucket_name
file_io = io.BytesIO(file_data)
blob.upload_from_file(file_io)
# Define the lifecycle rule to delete objects after 6 hours
rule = {
"action": {"type": "Delete"},
"condition": {"age": 1} # Age in days (24 hours = 1 days)
}
# rule = {
# "action": {"type": "Delete"},
# "condition": {"age": 1} # Age in days (24 hours = 1 days)
# }

# Get the current lifecycle policy
lifecycle = list(bucket.lifecycle_rules)
# # Get the current lifecycle policy
# lifecycle = list(bucket.lifecycle_rules)

# Add the new rule
lifecycle.append(rule)
# # Add the new rule
# lifecycle.append(rule)

# Set the lifecycle policy on the bucket
bucket.lifecycle_rules = lifecycle
bucket.patch()
# # Set the lifecycle policy on the bucket
# bucket.lifecycle_rules = lifecycle
# bucket.patch()
time.sleep(1)
logging.info('Chunk uploaded successfully in gcs')

def merge_file_gcs(bucket_name, original_file_name: str):
Expand Down