updated Empty Runner
This commit is contained in:
28
EmptyRunner/Dockerfile
Normal file
28
EmptyRunner/Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends gcc \
|
||||
&& rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry
|
||||
|
||||
# Copy Poetry configuration
|
||||
COPY /pyproject.toml ./pyproject.toml
|
||||
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge \
|
||||
&& rm -rf ~/.cache/pypoetry
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
COPY /EmptyRunner .
|
||||
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/ \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "app.py"]
|
||||
5
EmptyRunner/app.py
Normal file
5
EmptyRunner/app.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# Try Redis
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
67
EmptyRunner/mongo_app.py
Normal file
67
EmptyRunner/mongo_app.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import arrow
|
||||
from uuid import uuid4
|
||||
|
||||
from Services.MongoService.provider import MongoProvider
|
||||
from Configs.mongo import MongoConfig
|
||||
|
||||
"""
|
||||
URL mongodb://mongo_user:mongo_password@10.10.2.36:11777/mongo_database?retryWrites=true&w=majority
|
||||
mongo_provider <Services.MongoService.provider.MongoProvider object at 0x7fe4c1f9a6f0>
|
||||
uu_id_key 5f2ab2b3-87ff-4ca6-9186-ec8b8a25fd7e
|
||||
|
||||
insert_one_result InsertOneResult(ObjectId('67dd92d5f23084946d88de9e'), acknowledged=True)
|
||||
update_one_result UpdateResult({'n': 1, 'nModified': 1, 'ok': 1.0, 'updatedExisting': True}, acknowledged=True)
|
||||
find_one_result :
|
||||
{
|
||||
'_id': ObjectId('67dd95cec132281e8e593683'), 'date': '2025-03-21', 'uuid': 'f27b7a50-1b00-4369-95f8-d1afdec55605',
|
||||
'data': 'Test data', 'added': 'Added data'
|
||||
}
|
||||
find_many_result : [
|
||||
{'_id': ObjectId('67dd95f687d6e0bfde791431'), 'date': '2025-03-21', 'uuid': 'f5d281ba-498f-4e2b-8c75-8c4db6312e85',
|
||||
'data': 'Updated Test data', 'added': 'Added data'},
|
||||
{'_id': ObjectId('67dd96ff0ace2f49b9e56c7a'), 'date': '2025-03-21', 'uuid': 'dd750ad2-a3b3-4879-997b-65fa74b3171b',
|
||||
'data': 'Updated Test data', 'added': 'Added data'},
|
||||
{'_id': ObjectId('67dd973966ee138cddcab371'), 'date': '2025-03-21', 'uuid': '0b0c5d4e-500f-410f-8919-2038ecc4bc8e',
|
||||
'data': 'Updated Test data', 'added': 'Added data'}
|
||||
]
|
||||
"""
|
||||
if __name__ == "__main__":
|
||||
# Create a new instance of the EmptyRunner class
|
||||
print('URL', MongoConfig.URL)
|
||||
with MongoProvider.mongo_client() as client:
|
||||
current_date = str(arrow.now().date())
|
||||
mongo_provider = MongoProvider(
|
||||
client=client,
|
||||
database=MongoConfig.DATABASE_NAME,
|
||||
storage_reason=["Collected", "Data", str(current_date)],
|
||||
)
|
||||
uu_id_key = str(uuid4())
|
||||
print('mongo_provider', mongo_provider)
|
||||
insert_one_result = mongo_provider.insert_one(
|
||||
document={
|
||||
"date": current_date,
|
||||
"uuid": uu_id_key,
|
||||
"data": "Test data",
|
||||
}
|
||||
)
|
||||
# str(insert_one_result.inserted_id)
|
||||
# insert_one_result.acknowledged
|
||||
print('uu_id_key', uu_id_key)
|
||||
print('insert_one_result', insert_one_result)
|
||||
update_one_result = mongo_provider.update_one(
|
||||
filter_query={"uuid": uu_id_key},
|
||||
update_data={"$set": {"added": "Added data", "data": "Updated Test data"}},
|
||||
)
|
||||
print('update_one_result', update_one_result)
|
||||
|
||||
find_many_result = mongo_provider.find_many(filter_query={"data": "Updated Test data"})
|
||||
print('find_many_result', find_many_result)
|
||||
|
||||
find_one_result = mongo_provider.find_one(filter_query={"added": "Added data"})
|
||||
print('find_one_result', find_one_result)
|
||||
|
||||
# Delete the document
|
||||
delete_result = mongo_provider.delete_one(filter_query={"uuid": uu_id_key})
|
||||
|
||||
# Delete multiple documents
|
||||
delete_many_result = mongo_provider.delete_many(filter_query={"added": "Added data"})
|
||||
45
EmptyRunner/postgres_app.py
Normal file
45
EmptyRunner/postgres_app.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from Schemas import AddressStreet, Users, Duty
|
||||
from Services.PostgresService.controllers.pagination_controllers import Pagination, PaginationConfig
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
db = AddressStreet.new_session()
|
||||
AddressStreet.pre_query = AddressStreet.filter_all(
|
||||
AddressStreet.street_name.ilike(
|
||||
"A%",
|
||||
),
|
||||
db=db,
|
||||
).core_query
|
||||
account_list = AddressStreet.filter_all(
|
||||
AddressStreet.expiry_starts >= "2000-01-01",
|
||||
AddressStreet.expiry_ends >= "2050-12-31",
|
||||
AddressStreet.street_name.ilike("%B%"),
|
||||
db=db,
|
||||
)
|
||||
pagination_config = PaginationConfig(
|
||||
page=200,
|
||||
size=50,
|
||||
order_field=["uu_id"],
|
||||
order_type=["asc"],
|
||||
)
|
||||
pagination = Pagination(data=account_list)
|
||||
pagination.change(config=pagination_config)
|
||||
|
||||
user_find_one = Users.filter_one(
|
||||
Users.uu_id == "45554ebb-422d-4da7-b89a-1fcfb7e41414",
|
||||
db=db,
|
||||
)
|
||||
user_wrong_find_one = Users.filter_one(
|
||||
Users.uu_id == "95554ebb-422d-4da7-b89a-1fcfb7e41414",
|
||||
db=db,
|
||||
)
|
||||
|
||||
created_duty = Duty.find_or_create(
|
||||
duty_name="Test",
|
||||
duty_code="T50",
|
||||
duty_description=1,
|
||||
db=db,
|
||||
)
|
||||
print('created_duty wrong', created_duty)
|
||||
created_duty.save(db=db)
|
||||
print('created_duty', created_duty)
|
||||
Reference in New Issue
Block a user