backend.ai icon indicating copy to clipboard operation
backend.ai copied to clipboard

fix: Replace `sessions`, `kernels`'s `status_history`'s type `map` with `list`

Open jopemachine opened this issue 2 years ago • 1 comments

refs #412, follow-up to #480

Checklist: (if applicable)

  • [ ] Milestone metadata specifying the target backport version
  • [x] Mention to the original issue
  • [ ] Documentation
  • [ ] API server-client counterparts (e.g., manager API -> client SDK)
  • [ ] Test case(s) to demonstrate the difference of before/after

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

This PR updates status_history to list type for saving all previous information and utilizing it.

Related issue: https://github.com/lablup/backend.ai/pull/1116

jopemachine avatar Oct 27 '23 05:10 jopemachine

Tested manually by writing some temporary client code.

    @api_function
    @pass_ctx_obj
    async def get_status_history(ctx: CLIContext, self):
        """
        Retrieves the status transition history of the compute session.
        """

        try:
            with Session() as session:
                fetch_func = lambda pg_offset, pg_size: session.ComputeSession.paginated_list(fields=(
                    session_fields["status_history"],
                    session_fields["status_history_log"],
                ))
                ctx.output.print_paginated_list(
                    fetch_func,
                    initial_page_offset=0,
                    page_size=20,
                )
        except Exception as e:
            ctx.output.print_error(e)
            sys.exit(ExitCode.FAILURE)

The result is as follows.

You can see status_history via graphene still use the same format, and the status_history_log uses the migrationed format.

스크린샷 2023-11-03 오후 12 10 39

jopemachine avatar Nov 03 '23 03:11 jopemachine

We also need to update clients using the session resource usage API handler's status_history field at: https://github.com/lablup/backend.ai/blob/e77c4a3cd79246541746fca5336a10261d7dc00b/src/ai/backend/manager/api/resource.py#L466 as this does not go through the GraphQL's backward-compatible field generation.

achimnol avatar May 03 '24 01:05 achimnol

Switching to another PR as we introduce Graphite. See #2116.

jopemachine avatar May 07 '24 08:05 jopemachine