refactoring
This commit is contained in:
parent
d140a1e2b3
commit
ae73420955
@ -9,7 +9,7 @@ RUN python -m pip install --upgrade pip
|
||||
|
||||
# Make a directory for the service files and copy the service repo into the container.
|
||||
WORKDIR /app/service
|
||||
COPY . ./
|
||||
COPY . .
|
||||
|
||||
# Install module & dependencies
|
||||
RUN python3 -m pip install -e .
|
||||
|
||||
29
README.md
29
README.md
@ -1,7 +1,34 @@
|
||||
# SETUP
|
||||
|
||||
```bash
|
||||
## 1. module
|
||||
|
||||
```bash
|
||||
pip install -e .
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## 1. docker image
|
||||
|
||||
```bash
|
||||
docker build -f Dockerfile -t pyinfra .
|
||||
```
|
||||
|
||||
# RUN
|
||||
|
||||
## 2. rabbitmq & minio
|
||||
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## 3. module
|
||||
|
||||
```bash
|
||||
python src/serve.py
|
||||
```
|
||||
|
||||
## 3. docker container
|
||||
|
||||
```bash
|
||||
docker run --net=host pyinfra
|
||||
```
|
||||
|
||||
@ -1,164 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
meta.helm.sh/release-name: red-research2
|
||||
meta.helm.sh/release-namespace: red-research2
|
||||
labels:
|
||||
apiVersion: v2
|
||||
app: image-service
|
||||
app.kubernetes.io/instance: red-research2
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: redaction
|
||||
helm.sh/chart: redaction
|
||||
io.cattle.field/appId: red-research2
|
||||
type: service
|
||||
name: mini-queue
|
||||
namespace: red-research2
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
apiVersion: v2
|
||||
app: image-service
|
||||
io.cattle.field/appId: red-research2
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
prometheus.io/path: /prometheus
|
||||
prometheus.io/port: "8080"
|
||||
prometheus.io/scrape: "true"
|
||||
labels:
|
||||
apiVersion: v2
|
||||
app: image-service
|
||||
io.cattle.field/appId: red-research2
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- image-service
|
||||
topologyKey: kubernetes.io/hostname
|
||||
weight: 100
|
||||
automountServiceAccountToken: false
|
||||
containers:
|
||||
- env:
|
||||
- name: BATCH_SIZE
|
||||
value: "32"
|
||||
- name: AVAILABLE_MEMORY
|
||||
value: "6000"
|
||||
- name: MINIMUM_FREE_MEMORY_PERCENTAGE
|
||||
value: "0.3"
|
||||
- name: RABBITMQ_HEARTBEAT
|
||||
value: "7200"
|
||||
- name: MONITOR_MEMORY_USAGE
|
||||
value: "true"
|
||||
- name: VERBOSE
|
||||
value: "true"
|
||||
- name: RUN_ID
|
||||
value: fabfb1f192c745369b88cab34471aba7
|
||||
- name: MIN_REL_IMAGE_SIZE
|
||||
value: "0.05"
|
||||
- name: MAX_REL_IMAGE_SIZE
|
||||
value: "0.75"
|
||||
- name: MIN_IMAGE_FORMAT
|
||||
value: "0.1"
|
||||
- name: MAX_IMAGE_FORMAT
|
||||
value: "10"
|
||||
- name: LOGGING_LEVEL_ROOT
|
||||
value: DEBUG
|
||||
- name: CONCURRENCY
|
||||
value: "1"
|
||||
- name: MONITORING_ENABLED
|
||||
value: "true"
|
||||
- name: RABBITMQ_HOST
|
||||
value: red-research2-rabbitmq
|
||||
- name: RABBITMQ_USERNAME
|
||||
value: user
|
||||
- name: RABBITMQ_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: rabbitmq-password
|
||||
name: red-research2-rabbitmq
|
||||
- name: STORAGE_ENDPOINT
|
||||
value: red-research2-minio-headless
|
||||
- name: STORAGE_BUCKET_NAME
|
||||
value: redaction
|
||||
optional: false
|
||||
- name: STORAGE_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: root-user
|
||||
name: red-research2-minio
|
||||
optional: false
|
||||
- name: STORAGE_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
key: root-password
|
||||
name: red-research2-minio
|
||||
optional: false
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: storage-backend
|
||||
optional: false
|
||||
image: nexus.iqser.com:5001/red/mini-queue-service-v1:latest
|
||||
imagePullPolicy: Always
|
||||
name: mini-queue
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
protocol: TCP
|
||||
resources:
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 4000Mi
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 2000Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: {}
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1001
|
||||
volumeMounts:
|
||||
- mountPath: /tmp
|
||||
name: tmp
|
||||
- mountPath: /app/service/incl/redai_image/data/tmp
|
||||
name: data-tmp
|
||||
- mountPath: /app/service/incl/image_service/data/mlruns/.trash
|
||||
name: trash
|
||||
imagePullSecrets:
|
||||
- name: nexus
|
||||
initContainers:
|
||||
- command:
|
||||
- sh
|
||||
- -c
|
||||
- until nc -z -w 10 red-research2-rabbitmq 5672; do echo waiting for rabbitmq;
|
||||
done; echo rabbitmq found
|
||||
image: nexus.iqser.com:5001/infra/busybox:1.33.1
|
||||
imagePullPolicy: Always
|
||||
name: init-rabbitmq
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1001
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: tmp
|
||||
- emptyDir: {}
|
||||
name: data-tmp
|
||||
- emptyDir: {}
|
||||
name: trash
|
||||
@ -21,8 +21,8 @@ if __name__ == "__main__":
|
||||
|
||||
for body in build_message_bodies():
|
||||
channel.basic_publish("", CONFIG.rabbitmq.queues.input, body)
|
||||
print(f" [x] Put {body} on {CONFIG.rabbitmq.queues.input}")
|
||||
print(f"Put {body} on {CONFIG.rabbitmq.queues.input}")
|
||||
|
||||
for method_frame, _, body in channel.consume(queue=CONFIG.rabbitmq.queues.output):
|
||||
print(json.loads(body))
|
||||
print(f"Received {json.loads(body)}")
|
||||
channel.basic_ack(method_frame.delivery_tag)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user