-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat: auditlogs 2 in vfolder #1822
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will review in detail after we determine to write the audit logs to DB or file system (I personally prefer to write them on DB because it will be hard to track all audit logs under HA setup)
If we decide to use DB for audit logs, then there should be 3 major works.
- update alembic migration files
- use SQLAlchemy ORM rather than a raw table
- change
AuditLog
graphene �class to graphene relay class. I can do this work if you don't mind!
try: | ||
return await handler(request) | ||
except Exception: | ||
raise | ||
finally: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | |
return await handler(request) | |
except Exception: | |
raise | |
finally: | |
try: | |
return await handler(request) | |
finally: |
you do not need to catch exception here unless you handle it
def updated_data(new_data: dict[str, Any]) -> dict[str, Any]: | ||
current_audit_log_data = audit_log_data.get().copy() | ||
return deep_update(current_audit_log_data, new_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def updated_data(new_data: dict[str, Any]) -> dict[str, Any]: | |
current_audit_log_data = audit_log_data.get().copy() | |
return deep_update(current_audit_log_data, new_data) | |
def update_audit_log_data(new_data: dict[str, Any]) -> None: | |
audit_log_data.set( | |
{**audit_log_data.get(), **new_data} | |
) |
This will work.
And let's not use pydantic v1 API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I think using this function is okay
https://docs.pydantic.dev/latest/migration/
this documents says it pydantic.v1.utils import deep_update
does not mean it has been deprecated!
Remove (unimplemented) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
May I update some codes that use SQLAlchemy APIs? We are planning to migrate to SQLAlchemy 2.0 and we should update some of the codes that are not compatible to 2.0 version
src/ai/backend/manager/models/alembic/versions/41f6bbb4a04a_add_audit_logs_table.py
Outdated
Show resolved
Hide resolved
src/ai/backend/manager/models/alembic/versions/41f6bbb4a04a_add_audit_logs_table.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove src/ai/__init__.py
and src/ai/backend/__init__.py
as these are namespace packages.
revived
#698
📚 Documentation preview 📚: https://sorna--1822.org.readthedocs.build/en/1822/
📚 Documentation preview 📚: https://sorna-ko--1822.org.readthedocs.build/ko/1822/