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

New admin-area task page #480

Closed
tcompa opened this issue May 7, 2024 · 6 comments
Closed

New admin-area task page #480

tcompa opened this issue May 7, 2024 · 6 comments

Comments

@tcompa
Copy link
Collaborator

tcompa commented May 7, 2024

As of the upcoming 2.0.5 version, fractal-server has a new superuser-only GET /admin/v2/task/ endpoint (thanks @ychiucco!). This is a first version of this endpoint, which we can still refine in the future. Its first use case is to help with issues like fractal-analytics-platform/fractal-server#1457.


It's a GET request (without request body), with a bunch of optional query parameters to filter the task list:

    id: Optional[int] = None,   # if set, only find the single task with this ID
    source: Optional[str] = None,    # if set, only find tasks with source that contains (case-insensitive) this string
    version: Optional[str] = None,   # if set, only find tasks with this version
    name: Optional[str] = None,    # if set, only find tasks with name that contains (case-insensitive) this string
    owner: Optional[str] = None,   # if set, only find tasks with this owner
    kind: Optional[Literal["common", "users"]] = None,    # if set to common, only find tasks with owner=None. if set to users, only find tasks with non-None owner
    max_number_of_results: int = 25,  # this is provisionally here, to avoid creating very large response bodies. After playing a bit with a real-life database we can refine this default value, or even remove this query parameter.

On this page, the admin can set some query filters for tasks, and get a list of enriched task objects. Each one of this objects has some basic task properties (id, name, commands, ..) and a list of relationships (including the list of workflows-projects-users associated to it).

The specific response-body models are available in https://fractal-analytics-platform.github.io/fractal-server/openapi/openapi.json (see also https://github.com/fractal-analytics-platform/fractal-server/blob/main/fractal_server/app/routes/admin/v2.py), and an example response body (fractal-analytics-platform/fractal-server#1465 (comment)) looks like

[
  {
    "task": {
      "id": 1,
      "name": "Foo",
      "type": "compound",
      "command_non_parallel": "cmd_non_parallel",
      "command_parallel": "cmd_parallel",
      "source": "xxx",
      "owner": "alice",
      "version": "0"
    },
    "relationships": [
      {
        "workflow_id": 1,
        "workflow_name": "My Workflow",
        "project_id": 1,
        "project_name": "project",
        "project_users": [
          {
            "id": 1,
            "email": "[email protected]"
          }
        ]
      },
      {
        "workflow_id": 2,
        "workflow_name": "My Workflow",
        "project_id": 1,
        "project_name": "project",
        "project_users": [
          {
            "id": 1,
            "email": "[email protected]"
          }
        ]
      }
    ]
  },
  {
    "task": {
      "id": 2,
      "name": "abcdef",
      "type": "compound",
      "command_non_parallel": "cmd_non_parallel",
      "command_parallel": "cmd_parallel",
      "source": "yyy",
      "owner": "bob",
      "version": "0"
    },
    "relationships": [
      {
        "workflow_id": 2,
        "workflow_name": "My Workflow",
        "project_id": 1,
        "project_name": "project",
        "project_users": [
          {
            "id": 1,
            "email": "[email protected]"
          }
        ]
      }
    ]
  },
  {
    "task": {
      "id": 3,
      "name": "task3",
      "type": "compound",
      "command_non_parallel": "cmd_non_parallel",
      "command_parallel": "cmd_parallel",
      "source": "source3",
      "owner": null,
      "version": "3"
    },
    "relationships": []
  }
]
@tcompa
Copy link
Collaborator Author

tcompa commented May 7, 2024

(fractal-server v2.0.5 is now available on PyPI)

@zonia3000
Copy link
Collaborator

This is a first version of the tasks admin page.

To avoid having a too big table I've displayed only some data in the table and I added an "Info" button that opens a modal showing the complete information.

I'm not sure if we have to display the source column, since its content is usually quite long, but I think it would be a bit weird to have it in the filters and not in the table.

image

The info modal displays the task properties and task relationships in separate accordions:

image

image

image

I think we can use a dropdown to select the owner filter. I'm currently filling the list using the usernames, falling back to the email if the username is null. Is this approach correct?

I imagined that a Delete button could be also useful but I'm not sure if we want to implement a mechanism that first delete all the references and then deletes the task.

I've also started to see this error:

image

How we should handle this case? Should I add the max_number_of_results in the form and leave the error as it is?

@tcompa
Copy link
Collaborator Author

tcompa commented May 9, 2024

I think we can use a dropdown to select the owner filter. I'm currently filling the list using the usernames, falling back to the email if the username is null. Is this approach correct?

The correct fallback is slightly different.
If username is set, this is the value to use. If not, we should look for the slurm_user property of the user. If not even that one is set, then there is no additional fallback.

@tcompa
Copy link
Collaborator Author

tcompa commented May 9, 2024

How we should handle this case? Should I add the max_number_of_results in the form and leave the error as it is?

We included this option provisionally, until we test this page/endpoint a bit further.
It's not urgent to handle this error in any special way, but if you can also expose this value in the form maybe it's the easiest solution for the moment. I think we'll revisit this feature in the future, anyway.

@tcompa
Copy link
Collaborator Author

tcompa commented May 9, 2024

Addendum to our ongoing discussion

The "info" messages could look like this:

  • name: Only include a task if its name contains this value (case insensitive).
  • kind: If common, only include tasks with null owner. If users, only include tasks with non-null owner.
  • owner: Only include a task if its owner matches this value.
  • source: Only include a task if its source contains this value (case insensitive).
  • version: Only include a task if its version matches this value.
  • id: Only include the task with this id (if any).
  • max_number_of_results: Upper limit on the number of tasks in the response.

@tcompa
Copy link
Collaborator Author

tcompa commented May 13, 2024

now closed with #484

@tcompa tcompa closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants