Skip to content
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: Replace sessions, kernels's status_history's type dict with list #3201

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

jopemachine
Copy link
Member

@jopemachine jopemachine commented Dec 5, 2024

Resolves #3200 (BA-20), Part of #3214 (BA-14).
Refs #412, follow-up to #480.

The current implementation saves only the most recent timestamp whenever status information in status_history is updated, and all previous information is deleted.

This PR prevents the loss of timestamp information by changing the data structure of sessions, kernels's status_history to List.

Previous format:

{
  "PENDING": "2024-01-01T00:00:05Z",
  "SCHEDULED": "2024-01-01T00:00:10Z",
  "PREPARING": "2024-01-01T00:00:12Z",
  "RESTARTING": "2024-01-01T00:30:00Z",
  "RUNNING": "2024-01-01T00:30:08Z",  // overwritten if restarted
}

New format:

[
  {"status": "PENDING", "timestamp": "2024-01-01T00:00:05Z"},
  {"status": "SCHEDULED", "timestamp": "2024-01-01T00:00:05Z"},
  {"status": "PREPARING", "timestamp": "2024-01-01T00:00:05Z"},
  {"status": "RUNNING", "timestamp": "2024-01-01T00:00:15Z"},  // preserved
  {"status": "RESTARTING", "timestamp": "2024-01-01T00:30:00Z"},
  {"status": "RUNNING", "timestamp": "2024-01-01T00:30:08Z"},
]

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • API server-client counterparts (e.g., manager API -> client SDK)

📚 Documentation preview 📚: https://sorna--3201.org.readthedocs.build/en/3201/


📚 Documentation preview 📚: https://sorna-ko--3201.org.readthedocs.build/ko/3201/

@github-actions github-actions bot added area:docs Documentations comp:manager Related to Manager component comp:client Related to Client component comp:cli Related to CLI component require:db-migration Automatically set when alembic migrations are added or updated labels Dec 5, 2024
@github-actions github-actions bot added the size:XL 500~ LoC label Dec 5, 2024
@jopemachine jopemachine added this to the 24.12 milestone Dec 5, 2024
@jopemachine jopemachine added type:feature Add new features type:refactor Refactor codes or add tests. labels Dec 5, 2024
@jopemachine jopemachine marked this pull request as ready for review December 5, 2024 06:03
@jopemachine
Copy link
Member Author

jopemachine commented Dec 5, 2024

@HyeockJinKim How can we specifically implement a length restriction?
We need to decide whether the length restriction should be configurable, whether older logs in the status_history_log list should simply be deleted when the limit is exceeded, and whether a warning log should be printed during the deletion process.

@jopemachine jopemachine force-pushed the topic/12-05-feat_replace_sessions_kernels_s_status_history_s_type_dict_with_list_ branch 4 times, most recently from 656df34 to dceabcc Compare December 10, 2024 00:38
@jopemachine
Copy link
Member Author

Broken CI will be fixed in #3235.

@jopemachine jopemachine force-pushed the topic/12-05-feat_replace_sessions_kernels_s_status_history_s_type_dict_with_list_ branch from 850165f to 98c21c0 Compare December 13, 2024 00:58
@@ -844,48 +846,63 @@ def logs(session_id: str, kernel: str | None) -> None:
sys.exit(ExitCode.FAILURE)


@session.command("status-history")
@session.command()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about session.command, but can you subtract the internal string "status-history"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@main.group()
def session():
"""Set of compute session operations"""

Looking at the code, it seems that the decorator itself does not perform any operations on the arguments.
So, I think it would be better to leave the arguments empty, as is currently done in most of the other code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is using overload to overload the function for the last implementation, can you double check? @jopemachine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no value is passed as an argument, the decorated function name is automatically used as the CLI command.
If we pass an arbitrary string, that string can be used as the CLI command instead of changing the function name.
So, let's leave the arguments empty here, just like with the other functions.

Comment on lines +59 to +62
case JSONArrayFieldItem(_col_name, _conditions, _key_name):
# TODO: Implement this.
pass
# ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it handled in a follow-up PR?

Copy link
Member Author

@jopemachine jopemachine Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code requires discussion before going ahead.
I created a Teams thread, but I haven’t received any responses yet.

@Yaminyam Yaminyam requested a review from Copilot December 18, 2024 09:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 21 changed files in this pull request and generated 1 comment.

Files not reviewed (15)
  • src/ai/backend/manager/api/schema.graphql: Language not supported
  • src/ai/backend/manager/models/minilang/queryfilter.py: Evaluated as low risk
  • src/ai/backend/client/cli/session/lifecycle.py: Evaluated as low risk
  • src/ai/backend/client/output/fields.py: Evaluated as low risk
  • src/ai/backend/client/utils.py: Evaluated as low risk
  • changes/3201.feature.md: Evaluated as low risk
  • src/ai/backend/manager/server.py: Evaluated as low risk
  • src/ai/backend/manager/scheduler/dispatcher.py: Evaluated as low risk
  • src/ai/backend/manager/registry.py: Evaluated as low risk
  • src/ai/backend/manager/models/utils.py: Evaluated as low risk
  • src/ai/backend/manager/models/session.py: Evaluated as low risk
  • src/ai/backend/manager/models/resource_usage.py: Evaluated as low risk
  • src/ai/backend/manager/api/resource.py: Evaluated as low risk
  • src/ai/backend/manager/models/gql_models/kernel.py: Evaluated as low risk
  • src/ai/backend/manager/models/minilang/ordering.py: Evaluated as low risk

src/ai/backend/manager/models/gql_models/session.py Outdated Show resolved Hide resolved
@jopemachine jopemachine force-pushed the topic/12-05-feat_replace_sessions_kernels_s_status_history_s_type_dict_with_list_ branch from 0eb0792 to 2b58767 Compare December 23, 2024 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:docs Documentations comp:cli Related to CLI component comp:client Related to Client component comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:XL 500~ LoC type:feature Add new features type:refactor Refactor codes or add tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change the status_history column in the kernels and sessions tables to list.
3 participants