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

[Bug] Limiting status output falsly claims "Task list is empty" #508

Closed
Cook-I-T opened this issue Mar 12, 2024 · 5 comments
Closed

[Bug] Limiting status output falsly claims "Task list is empty" #508

Cook-I-T opened this issue Mar 12, 2024 · 5 comments
Labels
s: Client This issue touches the pueue client t: Bug

Comments

@Cook-I-T
Copy link

Describe the bug

I tried to check in a Bash script if there's still a task running in a certain group with the bash command pueue status -g group columns=Status status=running first 1 | grep 'Running' | wc -l
I expect that when a group still has any running task it outputs one row of "Running" which gets converted to a 1, with nothing running outputting 0.

Steps to reproduce

  • Add 2 groups
  • Add multiple Tasks to both of them
  • Now query the status of the groups with pueue status -g {GROUPNAME} columns=Status status=running first 1
  • One group will say the expected "Status" Column with one row saying "Running" while the other falsly outputs "Task list is empty."
cookit@cook-pc:~$ pueue group add g1
Group "g1" is being created
cookit@cook-pc:~$ pueue group add g2
Group "g2" is being created
cookit@cook-pc:~$ pueue add -g g1 sleep 60
New task added (id 0).
cookit@cook-pc:~$ pueue add -g g1 sleep 60
New task added (id 1).
cookit@cook-pc:~$ pueue add -g g1 sleep 60
New task added (id 2).
cookit@cook-pc:~$ pueue add -g g2 sleep 60
New task added (id 3).
cookit@cook-pc:~$ pueue add -g g2 sleep 60
New task added (id 4).
cookit@cook-pc:~$ pueue add -g g2 sleep 60
New task added (id 5).
cookit@cook-pc:~$ pueue status -g g1 columns=Status status=running first 1
Group "g1" (1 parallel): running
─────────
 Status  
═════════
 Running 
─────────
cookit@cook-pc:~$ pueue status -g g2 columns=Status status=running first 1
Group "g2" (1 parallel): running
Task list is empty. Add tasks with `pueue add -g g2 -- [cmd]`
cookit@cook-pc:~$ pueue
Group "g1" (1 parallel): running
─────────────────────────────────────────────────────────
 Id   Status    Command    Path           Start      End 
═════════════════════════════════════════════════════════
 0    Running   sleep 60   /home/cookit   20:56:15       
─────────────────────────────────────────────────────────
 1    Queued    sleep 60   /home/cookit                  
─────────────────────────────────────────────────────────
 2    Queued    sleep 60   /home/cookit                  
─────────────────────────────────────────────────────────

Group "g2" (1 parallel): running
─────────────────────────────────────────────────────────
 Id   Status    Command    Path           Start      End 
═════════════════════════════════════════════════════════
 3    Running   sleep 60   /home/cookit   20:56:20       
─────────────────────────────────────────────────────────
 4    Queued    sleep 60   /home/cookit                  
─────────────────────────────────────────────────────────
 5    Queued    sleep 60   /home/cookit                  
─────────────────────────────────────────────────────────
cookit@cook-pc:~$ pueue status -g g2 columns=Status status=running first 1
Group "g2" (1 parallel): running
Task list is empty. Add tasks with `pueue add -g g2 -- [cmd]`
cookit@cook-pc:~$ pueue status -g g1 columns=Status status=running first 1
Group "g1" (1 parallel): running
─────────
 Status  
═════════
 Running 
─────────

Debug logs (if relevant)

cookit@cook-pc:~$ pueue -vvv status -g g1 columns=Status status=running first 1
21:01:02 [INFO] Parsing config files
21:01:02 [INFO] Checking path: "/home/cookit/.config/pueue/pueue.yml"
21:01:02 [INFO] Found config file at: "/home/cookit/.config/pueue/pueue.yml"
21:01:02 [DEBUG] (1) pueue_lib::network::protocol: Sending message: Status
21:01:02 [DEBUG] (1) pueue_lib::network::protocol: Received message: StatusResponse(
    State {
        tasks: {
            0: Task {
                id: 0,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Running,
                prev_status: Locked,
                start: Some(
                    2024-03-12T21:00:37.595571177+01:00,
                ),
                end: None,
            },
            1: Task {
                id: 1,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            2: Task {
                id: 2,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            3: Task {
                id: 3,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Running,
                prev_status: Locked,
                start: Some(
                    2024-03-12T21:00:43.598473578+01:00,
                ),
                end: None,
            },
            4: Task {
                id: 4,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            5: Task {
                id: 5,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
        },
        groups: {
            "default": Group {
                status: Running,
                parallel_tasks: 1,
            },
            "g1": Group {
                status: Running,
                parallel_tasks: 1,
            },
            "g2": Group {
                status: Running,
                parallel_tasks: 1,
            },
        },
    },
)
Group "g1" (1 parallel): running
─────────
 Status  
═════════
 Running 
─────────
cookit@cook-pc:~$ pueue -vvv status -g g2 columns=Status status=running first 1
21:01:14 [INFO] Parsing config files
21:01:14 [INFO] Checking path: "/home/cookit/.config/pueue/pueue.yml"
21:01:14 [INFO] Found config file at: "/home/cookit/.config/pueue/pueue.yml"
21:01:14 [DEBUG] (1) pueue_lib::network::protocol: Sending message: Status
21:01:14 [DEBUG] (1) pueue_lib::network::protocol: Received message: StatusResponse(
    State {
        tasks: {
            0: Task {
                id: 0,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Running,
                prev_status: Locked,
                start: Some(
                    2024-03-12T21:00:37.595571177+01:00,
                ),
                end: None,
            },
            1: Task {
                id: 1,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            2: Task {
                id: 2,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g1",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            3: Task {
                id: 3,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Running,
                prev_status: Locked,
                start: Some(
                    2024-03-12T21:00:43.598473578+01:00,
                ),
                end: None,
            },
            4: Task {
                id: 4,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
            5: Task {
                id: 5,
                original_command: "sleep 60",
                command: "sleep 60",
                path: "/home/cookit",
                envs: "hidden",
                group: "g2",
                dependencies: [],
                label: None,
                status: Queued,
                prev_status: Locked,
                start: None,
                end: None,
            },
        },
        groups: {
            "default": Group {
                status: Running,
                parallel_tasks: 1,
            },
            "g1": Group {
                status: Running,
                parallel_tasks: 1,
            },
            "g2": Group {
                status: Running,
                parallel_tasks: 1,
            },
        },
    },
)
Group "g2" (1 parallel): running
Task list is empty. Add tasks with `pueue add -g g2 -- [cmd]`
cookit@cook-pc:~$ 

Operating system

Debian 11

Pueue version

3.3.3

Additional context

No response

@Nukesor
Copy link
Owner

Nukesor commented Mar 13, 2024

True, that seems to be a bug.

Feel free to investigate and create a PR :) I'm not sure when I have the time to look at this.

@Nukesor Nukesor added t: Bug s: Client This issue touches the pueue client labels Mar 13, 2024
@Cook-I-T
Copy link
Author

I looked at the code in pueue/src/client/query/ but since I never worked with Rust (and never heard of pest before) I sadly can't help with fixing that bug :(
I did figure out that increasing the number somehow makes lines appear again (so for example first 2 shows 1 line of "Running"), but it's not consistent.

For my usecase however I did realise that columns=Status status=running is already limiting the lines of output to the "parallel" count of the group, which makes the magical performance & efficiency I hoped to gain from first 1 kinda irrelevant. I just added a quick head -n 1 after grep and I'm back to the "0 or 1" output I want :)


Thanks for developing this amazing tool, if there's a way to support this project outside of PRs I'd gladly help :)
Vielen Dank aus Österreich ^_^

@Shakil582
Copy link

Shakil582 commented Mar 18, 2024

submitted a fix here #512

@Cook-I-T
Copy link
Author

submitted a fix here #512

Thanks for fixing my bug report!
I installed rust, compiled your fork and from what I can see, it fixes the problem :)
Now it just requires @Nukesor's approval and another bug is squashed ^_^

@Cook-I-T
Copy link
Author

I was just compiling the " fix-group-filtering" branch when it got merged, (again) from what I see it fixes the issue, looking at the changes I again have no idea how it works but it does :)
I'm not sure if I should close this issue or not so I'll just leave it...

Thanks again for all the good work! ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: Client This issue touches the pueue client t: Bug
Projects
None yet
Development

No branches or pull requests

3 participants