import boto3
import datetime
def create_config(self, context):
# Existing code...
# Define the date components
day = datetime.datetime.now().strftime("%d")
month = datetime.datetime.now().strftime("%m")
year = datetime.datetime.now().strftime("%Y")
# Initialize S3 client
s3_client = boto3.client("s3")
# Construct base S3 path using monitoring_uri and model_name
bucket_name = self.monitoring_uri.split('/')[2]
base_path = f"{'/'.join(self.monitoring_uri.split('/')[3:])}/{self.model_name}-monitor/{year}/{month}/{day}/"
# List objects within the specified day path to retrieve available hour folders
response = s3_client.list_objects_v2(Bucket=bucket_name, Prefix=base_path, Delimiter="/")
hour_folders = [content["Prefix"].split("/")[-2] for content in response.get("CommonPrefixes", [])]
# Use the first available hour folder if it exists
hour = hour_folders[0] if hour_folders else None
if hour:
# Construct the paths using the dynamically fetched hour
self.results_constraints_uri = f"{self.monitoring_uri}/{self.model_name}-monitor/{year}/{month}/{day}/{hour}/constraints.json"
self.results_statistics_uri = f"{self.monitoring_uri}/{self.model_name}-monitor/{year}/{month}/{day}/{hour}/statistics.json"
self.results_constraints_violations_uri = f"{self.monitoring_uri}/{self.model_name}-monitor/{year}/{month}/{day}/{hour}/constraint_violations.json"
else:
raise ValueError("No hour folders found in the specified S3 path.")
# Remaining code in the create_config function...
Ähnliche Beiträge
Auch interessante Nachrichten change s3 path for DQM
Thematisch verwandte Begriffe: change, path · 6 Treffer
NETWIRE Configuration Extractor
[webapps] Langflow 1.8.4 - Path Traversal to Remote Code Execution
EMOTET Configuration Extractor
🚨 Typosquatting packages on PyPI are targeting 𝗿𝗲𝗾𝘂𝗲𝘀𝘁𝘀, one of the most widely used Python packages. Catch them before compromise.
EMOTET Dynamic Configuration Extraction
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
Beiträge werden geladen ...
Videos werden geladen ...
SOCIAL SHARE CARD GENERATOR