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 map with list #2113

Closed
wants to merge 45 commits into from

Conversation

jopemachine
Copy link
Member

@jopemachine jopemachine commented May 7, 2024

Refs #412, follow-up to #480.
Related PR: #1116.

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--2113.org.readthedocs.build/en/2113/


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

@jopemachine jopemachine added this to the 24.09 milestone May 7, 2024
@jopemachine jopemachine self-assigned this May 7, 2024
Copy link

graphite-app bot commented May 7, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “flow:merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “flow:hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added area:docs Documentations comp:manager Related to Manager component comp:client Related to Client component comp:common Related to Common component comp:cli Related to CLI component require:db-migration Automatically set when alembic migrations are added or updated size:XL 500~ LoC labels May 7, 2024
@jopemachine jopemachine marked this pull request as ready for review May 7, 2024 08:06
@jopemachine jopemachine force-pushed the topic/05-07-refactor_status_history branch from 222dd6d to 24dfca2 Compare May 9, 2024 04:42
@achimnol achimnol force-pushed the topic/05-07-refactor_status_history branch 3 times, most recently from 5495f32 to b707634 Compare July 18, 2024 08:00
@achimnol achimnol force-pushed the topic/05-07-refactor_status_history branch 2 times, most recently from 2b525ff to 2d3e2b4 Compare July 22, 2024 17:01
jopemachine and others added 18 commits July 23, 2024 15:17
…manager.models.utils

- This eliminates the necessity to use stringified enum arguments in the
  `ai.backend.manager.models` codes.

- In the client SDK, add a copy of it using relaxed str-only arguments.
  Since this is a fairly simple logic, I think it is not worth to
  introduce additional complexity to share and reuse the code between
  the client SDK and the manager.
  (Note that originally `ai.backend.common` was not the dependency of
  the client SDK...)

- I think it would be better to introduce a JSON-fied TypedDict of each status
  history records.

- Also fix several merge errors.
@achimnol achimnol force-pushed the topic/05-07-refactor_status_history branch from 2d3e2b4 to 5eeb502 Compare July 23, 2024 06:18
Comment on lines +814 to +823
if (preparing := get_first_timestamp_for_status(status_history, "PREPARING")) is None:
elapsed = timedelta()
elif (
terminated := get_first_timestamp_for_status(status_history, "TERMINATED")
) is None:
elapsed = datetime.now(tzutc()) - preparing
else:
alloc_time: timedelta = isoparse(terminated) - isoparse(preparing)
result = {
"result": {
"seconds": alloc_time.seconds,
"microseconds": alloc_time.microseconds,
},
}
print_done(f"Actual Resource Allocation Time: {result}")
elapsed = terminated - preparing

print_done(f"Actual Resource Allocation Time: {elapsed.total_seconds()}")

Choose a reason for hiding this comment

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

You've probably kept the existing behavior based on dict, but since you've changed the structure based on list, shouldn't you show the whole history change?

@jopemachine jopemachine modified the milestones: 24.09, 24.12 Dec 5, 2024
@jopemachine jopemachine changed the title refactor: Replace sessions, kernels's status_history's type map with list feat: Replace sessions, kernels's status_history's type map with list Dec 5, 2024
@jopemachine jopemachine added type:refactor Refactor codes or add tests. type:feature Add new features labels Dec 5, 2024
@jopemachine
Copy link
Member Author

Since this PR adds or modifies the API, it has been changed to "feat".

@jopemachine
Copy link
Member Author

This original PR has become too outdated, requiring excessive effort to update, so a new PR has been created.
See #3201.

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:common Related to Common 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.

3 participants