Skip to content

Commit 9abfa3b

Browse files
Fix trailing whitespace issues to pass pre-commit checks
1 parent 1001e52 commit 9abfa3b

File tree

9 files changed

+169
-169
lines changed

9 files changed

+169
-169
lines changed

QUICK_START_LOGGING.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ codegen config telemetry enable
3838
# 2. Run the demo
3939
python example_enhanced_agent_command.py
4040

41-
# 3. Run any CLI command
41+
# 3. Run any CLI command
4242
codegen agents # or any other command
4343

4444
# 4. Check status
@@ -57,7 +57,7 @@ logger.info("Operation started", extra={
5757
"user_input": relevant_input
5858
})
5959

60-
# At end of function
60+
# At end of function
6161
logger.info("Operation completed", extra={
6262
"operation": "command.subcommand",
6363
"success": True
@@ -71,7 +71,7 @@ try:
7171
pass
7272
except SomeSpecificError as e:
7373
logger.error("Specific error occurred", extra={
74-
"operation": "command.subcommand",
74+
"operation": "command.subcommand",
7575
"error_type": "specific_error",
7676
"error_details": str(e)
7777
}, exc_info=True)
@@ -89,7 +89,7 @@ logger.info("Making API request", extra={
8989

9090
# After successful API call
9191
logger.info("API request successful", extra={
92-
"operation": "api.request",
92+
"operation": "api.request",
9393
"endpoint": "agent/run",
9494
"response_id": response.get("id"),
9595
"status_code": response.status_code
@@ -101,7 +101,7 @@ logger.info("API request successful", extra={
101101
### 🔥 High Priority (Add These First)
102102
- **Operation start/end**: When commands begin/complete
103103
- **API calls**: Requests to your backend
104-
- **Authentication events**: Login/logout/token issues
104+
- **Authentication events**: Login/logout/token issues
105105
- **Errors**: Any exception or failure
106106
- **User actions**: Commands run, options selected
107107

@@ -126,30 +126,30 @@ logger = get_logger(__name__)
126126

127127
def create(prompt: str, org_id: int | None = None, ...):
128128
"""Create a new agent run with the given prompt."""
129-
129+
130130
# ADD: Log start
131131
logger.info("Agent creation started", extra={
132132
"operation": "agent.create",
133133
"org_id": org_id,
134134
"prompt_length": len(prompt)
135135
})
136-
136+
137137
# Your existing code...
138138
try:
139139
response = requests.post(url, headers=headers, json=payload)
140140
agent_run_data = response.json()
141-
142-
# ADD: Log success
141+
142+
# ADD: Log success
143143
logger.info("Agent created successfully", extra={
144144
"operation": "agent.create",
145145
"agent_run_id": agent_run_data.get("id"),
146146
"status": agent_run_data.get("status")
147147
})
148-
148+
149149
except requests.RequestException as e:
150150
# ADD: Log error
151151
logger.error("Agent creation failed", extra={
152-
"operation": "agent.create",
152+
"operation": "agent.create",
153153
"error_type": "api_error",
154154
"error": str(e)
155155
})
@@ -165,28 +165,28 @@ logger = get_logger(__name__)
165165

166166
def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None:
167167
session_id = generate_session_id()
168-
168+
169169
# ADD: Log session start
170170
logger.info("Claude session started", extra={
171171
"operation": "claude.session_start",
172172
"session_id": session_id[:8], # Short version for privacy
173173
"org_id": resolved_org_id
174174
})
175-
175+
176176
# Your existing code...
177-
177+
178178
try:
179179
process = subprocess.Popen([claude_path, "--session-id", session_id])
180180
returncode = process.wait()
181-
181+
182182
# ADD: Log session end
183183
logger.info("Claude session completed", extra={
184184
"operation": "claude.session_complete",
185185
"session_id": session_id[:8],
186186
"exit_code": returncode,
187187
"status": "COMPLETE" if returncode == 0 else "ERROR"
188188
})
189-
189+
190190
except Exception as e:
191191
# ADD: Log session error
192192
logger.error("Claude session failed", extra={
@@ -201,14 +201,14 @@ def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None:
201201
After making changes:
202202

203203
1. **Run the command**: Execute your enhanced CLI command
204-
2. **Check telemetry status**: `codegen config telemetry status`
204+
2. **Check telemetry status**: `codegen config telemetry status`
205205
3. **Look for logs in Grafana Cloud**: Search for your operation names
206206
4. **Test with telemetry disabled**: `codegen config telemetry disable` - should still work normally
207207

208208
## 🚀 Progressive Enhancement
209209

210210
**Week 1**: Add basic operation logging to 2-3 commands
211-
**Week 2**: Add error logging to all commands
211+
**Week 2**: Add error logging to all commands
212212
**Week 3**: Add performance metrics and detailed context
213213
**Week 4**: Create Grafana dashboards using the collected data
214214

src/codegen/cli/commands/org/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _set_default_organization(org_id: int, cached_orgs: list[dict]) -> None:
7373

7474
# Set the environment variable
7575
os.environ["CODEGEN_ORG_ID"] = str(org_id)
76-
76+
7777
# Try to update .env file if it exists
7878
env_file_path = ".env"
7979
if os.path.exists(env_file_path):

src/codegen/cli/commands/org/tui.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,37 @@ def __init__(self):
2929
def compose(self) -> ComposeResult:
3030
"""Create child widgets for the app."""
3131
yield Header()
32-
32+
3333
if not self.organizations:
3434
yield Container(
35-
Static("⚠️ No organizations found. Please run 'codegen login' first.", classes="warning-message"),
35+
Static("⚠️ No organizations found. Please run 'codegen login' first.", classes="warning-message"),
3636
id="no-orgs-warning"
3737
)
3838
else:
3939
with Vertical():
4040
yield Static("🏢 Select Your Organization", classes="title")
4141
yield Static("Use ↑↓ to navigate, Enter to select, Q/Esc to quit", classes="help")
42-
42+
4343
table = DataTable(id="orgs-table", cursor_type="row")
4444
table.add_columns("Current", "ID", "Organization Name")
45-
45+
4646
# Get the actual current org ID (checks environment variables first)
4747
actual_current_org_id = resolve_org_id()
48-
48+
4949
for org in self.organizations:
5050
org_id = org["id"]
5151
org_name = org["name"]
5252
is_current = "●" if org_id == actual_current_org_id else " "
53-
53+
5454
table.add_row(is_current, str(org_id), org_name, key=str(org_id))
55-
55+
5656
yield table
57-
57+
5858
yield Static(
59-
"\n💡 Selecting an organization will update your CODEGEN_ORG_ID environment variable.",
59+
"\n💡 Selecting an organization will update your CODEGEN_ORG_ID environment variable.",
6060
classes="help"
6161
)
62-
62+
6363
yield Footer()
6464

6565
def on_mount(self) -> None:
@@ -89,7 +89,7 @@ def _handle_org_selection(self) -> None:
8989

9090
try:
9191
table = self.query_one("#orgs-table", DataTable)
92-
92+
9393
if table.cursor_row is not None and table.cursor_row < len(self.organizations):
9494
# Get the selected organization directly from the cursor position
9595
selected_org = self.organizations[table.cursor_row]
@@ -106,24 +106,24 @@ def _set_organization(self, org_id: int, org_name: str) -> None:
106106
"""Set the selected organization as default."""
107107
# Set environment variable
108108
os.environ["CODEGEN_ORG_ID"] = str(org_id)
109-
109+
110110
# Try to update .env file
111111
env_updated = self._update_env_file(org_id)
112-
112+
113113
if env_updated:
114114
self.notify(f"✓ Set default organization: {org_name} (ID: {org_id})")
115115
self.notify("✓ Updated .env file with CODEGEN_ORG_ID")
116116
else:
117117
self.notify(f"✓ Set organization: {org_name} (ID: {org_id})")
118118
self.notify("ℹ Add 'export CODEGEN_ORG_ID={org_id}' to your shell for persistence")
119-
119+
120120
# Wait a moment for user to see the notifications, then close
121121
self.set_timer(2.0, self._close_screen)
122122

123123
def _update_env_file(self, org_id: int) -> bool:
124124
"""Update the .env file with the new organization ID."""
125125
env_file_path = ".env"
126-
126+
127127
try:
128128
lines = []
129129
key_found = False
@@ -152,9 +152,9 @@ def _update_env_file(self, org_id: int) -> bool:
152152
# Write back to file
153153
with open(env_file_path, "w") as f:
154154
f.writelines(lines)
155-
155+
156156
return True
157-
157+
158158
except Exception:
159159
return False
160160

@@ -174,7 +174,7 @@ def action_quit(self) -> None:
174174

175175
class OrgSelectorApp(App):
176176
"""Standalone app wrapper for the organization selector."""
177-
177+
178178
CSS_PATH = "../../tui/codegen_theme.tcss" # Use custom Codegen theme
179179
TITLE = "Organization Selector - Codegen CLI"
180180
BINDINGS = [
@@ -191,37 +191,37 @@ def __init__(self):
191191
def compose(self) -> ComposeResult:
192192
"""Create child widgets for the app."""
193193
yield Header()
194-
194+
195195
if not self.organizations:
196196
yield Container(
197-
Static("⚠️ No organizations found. Please run 'codegen login' first.", classes="warning-message"),
197+
Static("⚠️ No organizations found. Please run 'codegen login' first.", classes="warning-message"),
198198
id="no-orgs-warning"
199199
)
200200
else:
201201
with Vertical():
202202
yield Static("🏢 Select Your Organization", classes="title")
203203
yield Static("Use ↑↓ to navigate, Enter to select, Q/Esc to quit", classes="help")
204-
204+
205205
table = DataTable(id="orgs-table", cursor_type="row")
206206
table.add_columns("Current", "ID", "Organization Name")
207-
207+
208208
# Get the actual current org ID (checks environment variables first)
209209
actual_current_org_id = resolve_org_id()
210-
210+
211211
for org in self.organizations:
212212
org_id = org["id"]
213213
org_name = org["name"]
214214
is_current = "●" if org_id == actual_current_org_id else " "
215-
215+
216216
table.add_row(is_current, str(org_id), org_name, key=str(org_id))
217-
217+
218218
yield table
219-
219+
220220
yield Static(
221-
"\n💡 Selecting an organization will update your CODEGEN_ORG_ID environment variable.",
221+
"\n💡 Selecting an organization will update your CODEGEN_ORG_ID environment variable.",
222222
classes="help"
223223
)
224-
224+
225225
yield Footer()
226226

227227
def on_mount(self) -> None:
@@ -251,7 +251,7 @@ def _handle_org_selection(self) -> None:
251251

252252
try:
253253
table = self.query_one("#orgs-table", DataTable)
254-
254+
255255
if table.cursor_row is not None and table.cursor_row < len(self.organizations):
256256
# Get the selected organization directly from the cursor position
257257
selected_org = self.organizations[table.cursor_row]
@@ -268,24 +268,24 @@ def _set_organization(self, org_id: int, org_name: str) -> None:
268268
"""Set the selected organization as default."""
269269
# Set environment variable
270270
os.environ["CODEGEN_ORG_ID"] = str(org_id)
271-
271+
272272
# Try to update .env file
273273
env_updated = self._update_env_file(org_id)
274-
274+
275275
if env_updated:
276276
self.notify(f"✓ Set default organization: {org_name} (ID: {org_id})")
277277
self.notify("✓ Updated .env file with CODEGEN_ORG_ID")
278278
else:
279279
self.notify(f"✓ Set organization: {org_name} (ID: {org_id})")
280280
self.notify("ℹ Add 'export CODEGEN_ORG_ID={org_id}' to your shell for persistence")
281-
281+
282282
# Wait a moment for user to see the notifications, then exit
283283
self.set_timer(2.0, self.exit)
284284

285285
def _update_env_file(self, org_id: int) -> bool:
286286
"""Update the .env file with the new organization ID."""
287287
env_file_path = ".env"
288-
288+
289289
try:
290290
lines = []
291291
key_found = False
@@ -314,9 +314,9 @@ def _update_env_file(self, org_id: int) -> bool:
314314
# Write back to file
315315
with open(env_file_path, "w") as f:
316316
f.writelines(lines)
317-
317+
318318
return True
319-
319+
320320
except Exception:
321321
return False
322322

0 commit comments

Comments
 (0)