Skip to content

rassokhina-e/python-api

Repository files navigation

# Test Python Servers: Sender & Consumer

A Python-based server architecture for processing images with metadata. This repository contains the configurations required to run local databases, execute database migrations, and configure Google Cloud Logging infrastructure for failed image routing.

---

## 🗂️ Project Documentation

For specific details regarding local testing and database schema changes, refer to the sub-directory documentation:
* **Testing Guidelines:** See [tests/README](tests/README) for running test suites.
* **Database Migrations:** See [migrations/README.md](migrations/README.md) for full migration workflows.

---

## 🚀 Quick Start: Local DB Setup

### 1. Make the Migration Script Executable
Before Docker can execute the orchestration script, the host operating system must grant it execution permissions. 

Run the following commands in your terminal:
```bash
# Grant execution permissions
chmod +x ./migrations/orchestrator.sh

# Verify the permissions were successfully updated
ls -l ./migrations/orchestrator.sh
```

---

## ☁️ Google Cloud Platform (GCP) Infrastructure Setup

Follow these steps to set up automated logging. This system monitors container terminal outputs and automatically routes specific image processing errors to a secure bucket.

### Step 1: Create a Cloud Storage Bucket
Define a destination folder in Google Cloud Storage to store your failed route logs.

1. Open the [Google Cloud Console](https://google.com).
2. Search for and navigate to **Cloud Storage** > **Buckets**.
3. Click **Create**.
4. Enter a globally unique **Bucket Name** (e.g., `failed-image-logs`).
5. Leave all other settings at their default values.
6. Click **Create**.

### Step 2: Create the Log Router Sink
Configure a connector to watch your container's terminal output, filter for specific errors, and push them to your newly created bucket.

1. In the console search bar, search for **Logging** and select **Log Router**.
2. Click **Create Sink**.
3. Complete the configuration steps using the following parameters:


| Configuration Field | Value / Action |
| :--- | :--- |
| **Sink Name** | `route-failed-images-to-gcs` |
| **Sink Service** | Choose **Cloud Storage bucket** |
| **Sink Destination** | Select your bucket (e.g., `my-project-failed-image-logs`) |

4. Scroll down to the **Build inclusion filter** box.
5. Paste the exact query below to target specific failed events:

```query
jsonPayload.event_type="image_processing_failed"
severity="ERROR"
```

6. Click **Create Sink**.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors