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

Show full nodeID and executionID with --wide flag #4783

Merged

Conversation

wdbaruni
Copy link
Member

@wdbaruni wdbaruni commented Dec 18, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced display of job execution IDs and node information with improved formatting.
    • Updated job history representation with a more precise column naming convention.
  • Bug Fixes

    • Streamlined handling of execution IDs in job history display.
  • Chores

    • Removed obsolete HistoryTime column for cleaner output.

Copy link

linear bot commented Dec 18, 2024

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

This pull request introduces modifications across several CLI-related files, focusing on improving the display and handling of identifiers, columns, and job history information. The changes primarily involve updating column configurations, renaming certain columns, and refining how IDs and version information are presented in the command-line interface. The modifications aim to enhance the clarity and consistency of output across different command contexts.

Changes

File Change Summary
cmd/cli/job/executions.go Updated executionColumnID and executionColumnNodeID with new ID display configurations
cmd/cli/job/history.go Renamed HistoryTime column to HistoryDateTime
cmd/cli/node/columns.go Enhanced node information columns, added version details for architecture and OS
cmd/util/cols/history.go Removed HistoryTime column, updated HistoryExecID column configuration

Possibly related PRs

Poem

🐰 Columns dance, IDs shine bright,
Refactoring code with rabbit's might!
Width and format, now crystal clear,
CLI output brings technical cheer!
Hop, hop, hooray for clean display! 🖥️

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf0f35 and b3828ed.

📒 Files selected for processing (4)
  • cmd/cli/job/executions.go (1 hunks)
  • cmd/cli/job/history.go (1 hunks)
  • cmd/cli/node/columns.go (1 hunks)
  • cmd/util/cols/history.go (1 hunks)
🔇 Additional comments (4)
cmd/util/cols/history.go (1)

30-39: Verify the impact of showing full execution IDs

The changes to show full execution IDs align with the PR objectives, but we should verify:

  1. That the idgen.ShortIDLengthWithPrefix constant is appropriate for the column width
  2. That the UI remains readable with full IDs

Additionally, consider adding a comment explaining that this configuration supports the --wide flag behavior.

✅ Verification successful

Based on the search results, I can now generate the final response as the findings provide comprehensive information about the usage of both ShortIDLengthWithPrefix and ShortUUID across the codebase.

The ID length and shortening approach is consistently used across the codebase

The changes to show full execution IDs are well-aligned with existing patterns in the codebase:

  • ShortIDLengthWithPrefix is consistently used as the WidthMax for ID columns across multiple commands (job list, executions, node state)
  • ShortUUID is the standard width enforcer for UUID-based IDs throughout the CLI
  • The implementation in pkg/util/idgen/short_id.go shows this is a well-tested and documented functionality

The suggestion to add a comment about --wide flag behavior is a valid nitpick but not a functional concern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the length constant and its usage
rg "ShortIDLengthWithPrefix" --type go -A 2
# Check other places where ShortUUID is used
rg "ShortUUID" --type go -A 2

Length of output: 4626

cmd/cli/job/history.go (1)

Line range hint 91-95: LGTM: Column replacement improves time display clarity

The switch from HistoryTime to HistoryDateTime provides more detailed timestamp information, which is a good improvement.

cmd/cli/node/columns.go (1)

Line range hint 52-67: LGTM: Enhanced version information improves node details

The addition of architecture and OS columns provides valuable system information that can help with debugging and deployment decisions.

cmd/cli/job/executions.go (1)

Line range hint 41-54: Verify --wide flag setup

Before implementing the suggested changes, we need to ensure the --wide flag is properly set up and accessible to the column configurations.

✅ Verification successful

The --wide flag is properly set up and ready to use

The verification shows that the --wide flag is correctly implemented and accessible:

  • It's defined in cmd/util/flags/cliflags/output.go as a boolean flag
  • ExecutionOptions embeds output.OutputOptions which contains the Wide field
  • The output package properly handles the wide flag in table rendering by removing width constraints when the flag is enabled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if and where the --wide flag is defined

# Search for --wide flag definition in the codebase
rg -A 5 'AddFlagSet.*wide|Flag\(.*wide'

# Search for any usage of the wide flag in the output package
rg -A 5 'wide' pkg/util/output/

Length of output: 130


Script:

#!/bin/bash
# Let's try different approaches to locate the wide flag and output package

# Find the output package location
fd -t d output

# Search for wide flag in the entire codebase
rg -i --type go "wide.*flag|flag.*wide"

# Search for output package imports
rg -i --type go "^import.*output"

Length of output: 197


Script:

#!/bin/bash
# Let's check the output flag implementation and its usage

# Check the output flag implementation
cat cmd/util/flags/cliflags/output.go

# Check if ExecutionOptions embeds or uses the output format
rg -A 5 "type ExecutionOptions" cmd/cli/job/executions.go

# Check the output package in cmd/util/output
ls -la cmd/util/output/
cat cmd/util/output/*.go

Length of output: 10566

Comment on lines +20 to +24
ColumnConfig: table.ColumnConfig{
Name: "id",
WidthMax: idgen.ShortIDLengthWithPrefix,
WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortNodeID(col) }},
Value: func(node *models.NodeState) string { return node.Info.ID() },
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the implementation of ShortNodeID, I can now generate the final response:

ShortNodeID conflicts with full ID display objective

The current implementation of ShortNodeID actively shortens IDs:

  • For UUIDs: returns only the first segment (e.g., "78faf114" from a full UUID)
  • For libp2p IDs: truncates to first 8 characters
  • This contradicts the objective of showing full node IDs in the table

This creates an inconsistency where:

  • Value function returns the full ID: node.Info.ID()
  • But WidthMaxEnforcer forcibly shortens it using ShortNodeID
🔗 Analysis chain

Verify the node ID display behavior

The changes to show full node IDs align with the PR objectives. However:

  1. Ensure that idgen.ShortNodeID in WidthMaxEnforcer is consistent with the full ID display objective
  2. Verify that the UI remains readable with full node IDs

Consider adding a comment explaining the relationship between these settings and the --wide flag behavior.


Let me analyze the implementation of ShortNodeID to understand if it conflicts with the full ID display objective. Let's check the actual implementation and the ShortUUID function it uses.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the implementation of ShortNodeID
ast-grep --pattern 'func ShortNodeID($id) { $$$ }'
# Check other usages of ShortNodeID
rg "ShortNodeID" --type go -A 2

Length of output: 2214


Script:

#!/bin/bash
# Check the full implementation of ShortNodeID and ShortUUID
cat pkg/util/idgen/short_id.go

# Check if there's a --wide flag implementation that might affect this behavior
rg --type go "wide.*flag" -A 2

Length of output: 2111

Comment on lines +116 to +120
ColumnConfig: table.ColumnConfig{
Name: "Node ID",
WidthMax: idgen.ShortIDLengthWithPrefix,
WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortUUID(col) }},
Value: func(e *models.Execution) string { return e.NodeID },
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Implementation doesn't respect --wide flag for NodeID

Similar to the ID column, the NodeID column's implementation doesn't fulfill the PR objective of showing full IDs with the --wide flag.

Apply similar changes as suggested for the ID column:

 executionColumnNodeID = output.TableColumn[*models.Execution]{
 	ColumnConfig: table.ColumnConfig{
 		Name:             "Node ID",
-		WidthMax:         idgen.ShortIDLengthWithPrefix,
-		WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortUUID(col) }},
+		WidthMax:         func(cmd *cobra.Command) int {
+			if cmd.Flags().Changed("wide") {
+				return 0 // No max width for full ID
+			}
+			return idgen.ShortIDLengthWithPrefix
+		},
+		WidthMaxEnforcer: func(col string, maxLen int) string {
+			if maxLen == 0 {
+				return col // Return full ID
+			}
+			return idgen.ShortUUID(col)
+		}},
 	Value: func(e *models.Execution) string { return e.NodeID },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ColumnConfig: table.ColumnConfig{
Name: "Node ID",
WidthMax: idgen.ShortIDLengthWithPrefix,
WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortUUID(col) }},
Value: func(e *models.Execution) string { return e.NodeID },
ColumnConfig: table.ColumnConfig{
Name: "Node ID",
WidthMax: func(cmd *cobra.Command) int {
if cmd.Flags().Changed("wide") {
return 0 // No max width for full ID
}
return idgen.ShortIDLengthWithPrefix
},
WidthMaxEnforcer: func(col string, maxLen int) string {
if maxLen == 0 {
return col // Return full ID
}
return idgen.ShortUUID(col)
}},
Value: func(e *models.Execution) string { return e.NodeID },

Comment on lines +109 to +113
ColumnConfig: table.ColumnConfig{
Name: "ID",
WidthMax: idgen.ShortIDLengthWithPrefix,
WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortUUID(col) }},
Value: func(e *models.Execution) string { return e.ID },
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Implementation doesn't respect --wide flag for showing full IDs

The current implementation doesn't fulfill the PR objective of showing full IDs with the --wide flag. The Value function returns the full ID but the WidthMaxEnforcer always shortens it, regardless of the --wide flag state.

Consider this implementation:

 executionColumnID = output.TableColumn[*models.Execution]{
 	ColumnConfig: table.ColumnConfig{
 		Name:             "ID",
-		WidthMax:         idgen.ShortIDLengthWithPrefix,
-		WidthMaxEnforcer: func(col string, maxLen int) string { return idgen.ShortUUID(col) }},
+		WidthMax:         func(cmd *cobra.Command) int {
+			if cmd.Flags().Changed("wide") {
+				return 0 // No max width for full ID
+			}
+			return idgen.ShortIDLengthWithPrefix
+		},
+		WidthMaxEnforcer: func(col string, maxLen int) string {
+			if maxLen == 0 {
+				return col // Return full ID
+			}
+			return idgen.ShortUUID(col)
+		}},
 	Value: func(e *models.Execution) string { return e.ID },

Committable suggestion skipped: line range outside the PR's diff.

@wdbaruni wdbaruni merged commit 8f39ed6 into main Dec 18, 2024
13 of 14 checks passed
@wdbaruni wdbaruni deleted the eng-160-show-full-nodeid-and-executionid-with-wide-flag branch December 18, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant