Mahakii commited on
Commit
bdfd122
Β·
1 Parent(s): cadc45d

Issues fixed for deployment

Browse files
Dockerfile CHANGED
@@ -1,5 +1,9 @@
1
  # Use an official Python runtime as a parent image
2
- FROM python:3.10-slim
 
 
 
 
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
@@ -8,7 +12,8 @@ WORKDIR /app
8
  COPY feature-flag-agent-env/requirements.txt ./requirements.txt
9
 
10
  # Install dependencies securely
11
- RUN pip install --no-cache-dir -r requirements.txt
 
12
 
13
  # Copy the project source tree into the container
14
  COPY feature-flag-agent-env/ ./
 
1
  # Use an official Python runtime as a parent image
2
+ FROM python:3.11-slim
3
+
4
+ # Make logs more readable in containerized environments.
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PYTHONDONTWRITEBYTECODE=1
7
 
8
  # Set the working directory in the container
9
  WORKDIR /app
 
12
  COPY feature-flag-agent-env/requirements.txt ./requirements.txt
13
 
14
  # Install dependencies securely
15
+ RUN python -m pip install --upgrade pip && \
16
+ pip install --no-cache-dir -r requirements.txt
17
 
18
  # Copy the project source tree into the container
19
  COPY feature-flag-agent-env/ ./
feature-flag-agent-env/Dockerfile CHANGED
@@ -1,5 +1,9 @@
1
  # Use an official Python runtime as a parent image
2
- FROM python:3.10-slim
 
 
 
 
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
@@ -8,13 +12,14 @@ WORKDIR /app
8
  COPY requirements.txt .
9
 
10
  # Install dependencies securely without saving the cache to save space
11
- RUN pip install --no-cache-dir -r requirements.txt
 
12
 
13
  # Copy the rest of the project files into the container
14
  COPY . .
15
 
16
- # Expose port 8000 for local use
17
- EXPOSE 8000
18
 
19
  # Command to run the FastAPI app using uvicorn
20
- CMD ["uvicorn", "feature_flag_env.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
  # Use an official Python runtime as a parent image
2
+ FROM python:3.11-slim
3
+
4
+ # Make logs more readable in containerized environments.
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PYTHONDONTWRITEBYTECODE=1
7
 
8
  # Set the working directory in the container
9
  WORKDIR /app
 
12
  COPY requirements.txt .
13
 
14
  # Install dependencies securely without saving the cache to save space
15
+ RUN python -m pip install --upgrade pip && \
16
+ pip install --no-cache-dir -r requirements.txt
17
 
18
  # Copy the rest of the project files into the container
19
  COPY . .
20
 
21
+ # Expose the Hugging Face / OpenEnv port
22
+ EXPOSE 7860
23
 
24
  # Command to run the FastAPI app using uvicorn
25
+ CMD ["uvicorn", "feature_flag_env.server.app:app", "--host", "0.0.0.0", "--port", "7860"]
feature-flag-agent-env/tests/test_tool_interface.py CHANGED
@@ -40,7 +40,6 @@ def test_mock_github_tool():
40
 
41
  print(f" πŸ“Š Deployment status: {result.data['status']}")
42
  print(" βœ… Passed")
43
- return True
44
 
45
 
46
  def test_mock_datadog_tool():
@@ -62,7 +61,6 @@ def test_mock_datadog_tool():
62
  print(f" πŸ“Š Error rate: {result.data['latest_value']:.4f}")
63
  print(f" πŸ“Š Latency: {result2.data['latest_value']:.1f}ms")
64
  print(" βœ… Passed")
65
- return True
66
 
67
 
68
  def test_mock_slack_tool():
@@ -86,7 +84,6 @@ def test_mock_slack_tool():
86
 
87
  print(f" πŸ“Š Messages logged: {len(tool.message_log)}")
88
  print(" βœ… Passed")
89
- return True
90
 
91
 
92
  # ===========================================================================
@@ -103,7 +100,6 @@ def test_validation_unknown_action():
103
 
104
  print(f" πŸ“Š Error: {result.error}")
105
  print(" βœ… Passed")
106
- return True
107
 
108
 
109
  def test_validation_missing_params():
@@ -121,7 +117,6 @@ def test_validation_missing_params():
121
  assert "channel" in result.error
122
 
123
  print(" βœ… Passed")
124
- return True
125
 
126
 
127
  def test_rate_limiting():
@@ -141,7 +136,6 @@ def test_rate_limiting():
141
 
142
  print(f" πŸ“Š Calls made: {tool.call_count}")
143
  print(" βœ… Passed")
144
- return True
145
 
146
 
147
  def test_metrics_tracking():
@@ -162,7 +156,6 @@ def test_metrics_tracking():
162
 
163
  print(f" πŸ“Š Metrics: {metrics}")
164
  print(" βœ… Passed")
165
- return True
166
 
167
 
168
  # ===========================================================================
@@ -191,7 +184,6 @@ def test_tool_manager_register():
191
 
192
  print(f" πŸ“Š Connected tools: {manager.tool_names}")
193
  print(" βœ… Passed")
194
- return True
195
 
196
 
197
  def test_tool_manager_unknown_tool():
@@ -209,7 +201,6 @@ def test_tool_manager_unknown_tool():
209
 
210
  print(f" πŸ“Š Error: {result.error}")
211
  print(" βœ… Passed")
212
- return True
213
 
214
 
215
  def test_tool_memory():
@@ -233,7 +224,6 @@ def test_tool_memory():
233
 
234
  print(f" πŸ“Š Buffer size: {len(manager.memory.recent)}")
235
  print(" βœ… Passed")
236
- return True
237
 
238
 
239
  def test_tool_manager_reset():
@@ -254,7 +244,6 @@ def test_tool_manager_reset():
254
  assert manager.memory.last is None
255
 
256
  print(" βœ… Passed")
257
- return True
258
 
259
 
260
  # ===========================================================================
@@ -287,7 +276,6 @@ def test_env_tool_call_action():
287
  print(f" πŸ“Š Tool result: {response.observation.last_tool_result['action']}")
288
  print(f" πŸ“Š Reward: {response.reward:+.2f}")
289
  print(" βœ… Passed")
290
- return True
291
 
292
 
293
  def test_env_tool_call_prompt_string():
@@ -314,7 +302,6 @@ def test_env_tool_call_prompt_string():
314
 
315
  print(f" πŸ“Š Prompt length: {len(prompt)} chars")
316
  print(" βœ… Passed")
317
- return True
318
 
319
 
320
  def test_env_mixed_actions():
@@ -346,7 +333,6 @@ def test_env_mixed_actions():
346
 
347
  print(f" πŸ“Š Rollout: 0 β†’ 10 β†’ 10 (tool) β†’ 20")
348
  print(" βœ… Passed")
349
- return True
350
 
351
 
352
  def test_env_tools_disabled():
@@ -365,7 +351,6 @@ def test_env_tools_disabled():
365
 
366
  print(f" πŸ“Š Penalty reward: {response.reward:+.2f}")
367
  print(" βœ… Passed")
368
- return True
369
 
370
 
371
  def test_env_tool_call_invalid():
@@ -385,7 +370,6 @@ def test_env_tool_call_invalid():
385
 
386
  print(f" πŸ“Š Error: {response.observation.last_tool_result['error']}")
387
  print(" βœ… Passed")
388
- return True
389
 
390
 
391
  # ===========================================================================
@@ -409,7 +393,6 @@ def test_backward_compat():
409
  assert response.observation.current_rollout_percentage == 15.0
410
 
411
  print(" βœ… Passed")
412
- return True
413
 
414
 
415
  # ===========================================================================
 
40
 
41
  print(f" πŸ“Š Deployment status: {result.data['status']}")
42
  print(" βœ… Passed")
 
43
 
44
 
45
  def test_mock_datadog_tool():
 
61
  print(f" πŸ“Š Error rate: {result.data['latest_value']:.4f}")
62
  print(f" πŸ“Š Latency: {result2.data['latest_value']:.1f}ms")
63
  print(" βœ… Passed")
 
64
 
65
 
66
  def test_mock_slack_tool():
 
84
 
85
  print(f" πŸ“Š Messages logged: {len(tool.message_log)}")
86
  print(" βœ… Passed")
 
87
 
88
 
89
  # ===========================================================================
 
100
 
101
  print(f" πŸ“Š Error: {result.error}")
102
  print(" βœ… Passed")
 
103
 
104
 
105
  def test_validation_missing_params():
 
117
  assert "channel" in result.error
118
 
119
  print(" βœ… Passed")
 
120
 
121
 
122
  def test_rate_limiting():
 
136
 
137
  print(f" πŸ“Š Calls made: {tool.call_count}")
138
  print(" βœ… Passed")
 
139
 
140
 
141
  def test_metrics_tracking():
 
156
 
157
  print(f" πŸ“Š Metrics: {metrics}")
158
  print(" βœ… Passed")
 
159
 
160
 
161
  # ===========================================================================
 
184
 
185
  print(f" πŸ“Š Connected tools: {manager.tool_names}")
186
  print(" βœ… Passed")
 
187
 
188
 
189
  def test_tool_manager_unknown_tool():
 
201
 
202
  print(f" πŸ“Š Error: {result.error}")
203
  print(" βœ… Passed")
 
204
 
205
 
206
  def test_tool_memory():
 
224
 
225
  print(f" πŸ“Š Buffer size: {len(manager.memory.recent)}")
226
  print(" βœ… Passed")
 
227
 
228
 
229
  def test_tool_manager_reset():
 
244
  assert manager.memory.last is None
245
 
246
  print(" βœ… Passed")
 
247
 
248
 
249
  # ===========================================================================
 
276
  print(f" πŸ“Š Tool result: {response.observation.last_tool_result['action']}")
277
  print(f" πŸ“Š Reward: {response.reward:+.2f}")
278
  print(" βœ… Passed")
 
279
 
280
 
281
  def test_env_tool_call_prompt_string():
 
302
 
303
  print(f" πŸ“Š Prompt length: {len(prompt)} chars")
304
  print(" βœ… Passed")
 
305
 
306
 
307
  def test_env_mixed_actions():
 
333
 
334
  print(f" πŸ“Š Rollout: 0 β†’ 10 β†’ 10 (tool) β†’ 20")
335
  print(" βœ… Passed")
 
336
 
337
 
338
  def test_env_tools_disabled():
 
351
 
352
  print(f" πŸ“Š Penalty reward: {response.reward:+.2f}")
353
  print(" βœ… Passed")
 
354
 
355
 
356
  def test_env_tool_call_invalid():
 
370
 
371
  print(f" πŸ“Š Error: {response.observation.last_tool_result['error']}")
372
  print(" βœ… Passed")
 
373
 
374
 
375
  # ===========================================================================
 
393
  assert response.observation.current_rollout_percentage == 15.0
394
 
395
  print(" βœ… Passed")
 
396
 
397
 
398
  # ===========================================================================
logs/audit/audit_20260425.log ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {'timestamp': '2026-04-25T20:17:32.077394', 'user': 'test_agent', 'action': 'reset_environment', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {'episode_id': 'ep_123'}}
2
+ {'timestamp': '2026-04-25T20:17:32.080716', 'user': 'user1', 'action': 'reset', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {}}
3
+ {'timestamp': '2026-04-25T20:17:32.081144', 'user': 'user2', 'action': 'step', 'endpoint': '/step', 'method': 'POST', 'status_code': 200, 'details': {}}
4
+ {'timestamp': '2026-04-25T20:17:32.081468', 'user': 'user1', 'action': 'state', 'endpoint': '/state', 'method': 'GET', 'status_code': 200, 'details': {}}
5
+ {'timestamp': '2026-04-25T20:17:32.085183', 'user': 'user0', 'action': 'action0', 'endpoint': '/endpoint0', 'method': 'POST', 'status_code': 200, 'details': {}}
6
+ {'timestamp': '2026-04-25T20:17:32.085567', 'user': 'user1', 'action': 'action1', 'endpoint': '/endpoint1', 'method': 'POST', 'status_code': 200, 'details': {}}
7
+ {'timestamp': '2026-04-25T20:17:32.086000', 'user': 'user2', 'action': 'action2', 'endpoint': '/endpoint2', 'method': 'POST', 'status_code': 200, 'details': {}}
8
+ {'timestamp': '2026-04-25T20:17:32.086339', 'user': 'user3', 'action': 'action3', 'endpoint': '/endpoint3', 'method': 'POST', 'status_code': 200, 'details': {}}
9
+ {'timestamp': '2026-04-25T20:17:32.086887', 'user': 'user4', 'action': 'action4', 'endpoint': '/endpoint4', 'method': 'POST', 'status_code': 200, 'details': {}}
10
+ {'timestamp': '2026-04-25T20:18:14.283033', 'user': 'test_agent', 'action': 'reset_environment', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {'episode_id': 'ep_123'}}
11
+ {'timestamp': '2026-04-25T20:18:14.284070', 'user': 'user1', 'action': 'reset', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {}}
12
+ {'timestamp': '2026-04-25T20:18:14.284070', 'user': 'user2', 'action': 'step', 'endpoint': '/step', 'method': 'POST', 'status_code': 200, 'details': {}}
13
+ {'timestamp': '2026-04-25T20:18:14.286776', 'user': 'user1', 'action': 'state', 'endpoint': '/state', 'method': 'GET', 'status_code': 200, 'details': {}}
14
+ {'timestamp': '2026-04-25T20:18:14.286776', 'user': 'user0', 'action': 'action0', 'endpoint': '/endpoint0', 'method': 'POST', 'status_code': 200, 'details': {}}
15
+ {'timestamp': '2026-04-25T20:18:14.286776', 'user': 'user1', 'action': 'action1', 'endpoint': '/endpoint1', 'method': 'POST', 'status_code': 200, 'details': {}}
16
+ {'timestamp': '2026-04-25T20:18:14.290181', 'user': 'user2', 'action': 'action2', 'endpoint': '/endpoint2', 'method': 'POST', 'status_code': 200, 'details': {}}
17
+ {'timestamp': '2026-04-25T20:18:14.290181', 'user': 'user3', 'action': 'action3', 'endpoint': '/endpoint3', 'method': 'POST', 'status_code': 200, 'details': {}}
18
+ {'timestamp': '2026-04-25T20:18:14.290181', 'user': 'user4', 'action': 'action4', 'endpoint': '/endpoint4', 'method': 'POST', 'status_code': 200, 'details': {}}
19
+ {'timestamp': '2026-04-25T20:25:59.861719', 'user': 'test_agent', 'action': 'reset_environment', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {'episode_id': 'ep_123'}}
20
+ {'timestamp': '2026-04-25T20:25:59.866847', 'user': 'user1', 'action': 'reset', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {}}
21
+ {'timestamp': '2026-04-25T20:25:59.866847', 'user': 'user2', 'action': 'step', 'endpoint': '/step', 'method': 'POST', 'status_code': 200, 'details': {}}
22
+ {'timestamp': '2026-04-25T20:25:59.866847', 'user': 'user1', 'action': 'state', 'endpoint': '/state', 'method': 'GET', 'status_code': 200, 'details': {}}
23
+ {'timestamp': '2026-04-25T20:25:59.868855', 'user': 'user0', 'action': 'action0', 'endpoint': '/endpoint0', 'method': 'POST', 'status_code': 200, 'details': {}}
24
+ {'timestamp': '2026-04-25T20:25:59.868855', 'user': 'user1', 'action': 'action1', 'endpoint': '/endpoint1', 'method': 'POST', 'status_code': 200, 'details': {}}
25
+ {'timestamp': '2026-04-25T20:25:59.868855', 'user': 'user2', 'action': 'action2', 'endpoint': '/endpoint2', 'method': 'POST', 'status_code': 200, 'details': {}}
26
+ {'timestamp': '2026-04-25T20:25:59.868855', 'user': 'user3', 'action': 'action3', 'endpoint': '/endpoint3', 'method': 'POST', 'status_code': 200, 'details': {}}
27
+ {'timestamp': '2026-04-25T20:25:59.870863', 'user': 'user4', 'action': 'action4', 'endpoint': '/endpoint4', 'method': 'POST', 'status_code': 200, 'details': {}}
28
+ {'timestamp': '2026-04-25T20:26:16.812954', 'user': 'test_agent', 'action': 'reset_environment', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {'episode_id': 'ep_123'}}
29
+ {'timestamp': '2026-04-25T20:26:16.817040', 'user': 'user1', 'action': 'reset', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {}}
30
+ {'timestamp': '2026-04-25T20:26:16.823224', 'user': 'user2', 'action': 'step', 'endpoint': '/step', 'method': 'POST', 'status_code': 200, 'details': {}}
31
+ {'timestamp': '2026-04-25T20:26:16.823224', 'user': 'user1', 'action': 'state', 'endpoint': '/state', 'method': 'GET', 'status_code': 200, 'details': {}}
32
+ {'timestamp': '2026-04-25T20:26:16.827247', 'user': 'user0', 'action': 'action0', 'endpoint': '/endpoint0', 'method': 'POST', 'status_code': 200, 'details': {}}
33
+ {'timestamp': '2026-04-25T20:26:16.827247', 'user': 'user1', 'action': 'action1', 'endpoint': '/endpoint1', 'method': 'POST', 'status_code': 200, 'details': {}}
34
+ {'timestamp': '2026-04-25T20:26:16.829788', 'user': 'user2', 'action': 'action2', 'endpoint': '/endpoint2', 'method': 'POST', 'status_code': 200, 'details': {}}
35
+ {'timestamp': '2026-04-25T20:26:16.829788', 'user': 'user3', 'action': 'action3', 'endpoint': '/endpoint3', 'method': 'POST', 'status_code': 200, 'details': {}}
36
+ {'timestamp': '2026-04-25T20:26:16.829788', 'user': 'user4', 'action': 'action4', 'endpoint': '/endpoint4', 'method': 'POST', 'status_code': 200, 'details': {}}
37
+ {'timestamp': '2026-04-25T20:39:59.735325', 'user': 'test_agent', 'action': 'reset_environment', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {'episode_id': 'ep_123'}}
38
+ {'timestamp': '2026-04-25T20:39:59.737296', 'user': 'user1', 'action': 'reset', 'endpoint': '/reset', 'method': 'POST', 'status_code': 200, 'details': {}}
39
+ {'timestamp': '2026-04-25T20:39:59.737685', 'user': 'user2', 'action': 'step', 'endpoint': '/step', 'method': 'POST', 'status_code': 200, 'details': {}}
40
+ {'timestamp': '2026-04-25T20:39:59.738073', 'user': 'user1', 'action': 'state', 'endpoint': '/state', 'method': 'GET', 'status_code': 200, 'details': {}}
41
+ {'timestamp': '2026-04-25T20:39:59.740515', 'user': 'user0', 'action': 'action0', 'endpoint': '/endpoint0', 'method': 'POST', 'status_code': 200, 'details': {}}
42
+ {'timestamp': '2026-04-25T20:39:59.740905', 'user': 'user1', 'action': 'action1', 'endpoint': '/endpoint1', 'method': 'POST', 'status_code': 200, 'details': {}}
43
+ {'timestamp': '2026-04-25T20:39:59.741503', 'user': 'user2', 'action': 'action2', 'endpoint': '/endpoint2', 'method': 'POST', 'status_code': 200, 'details': {}}
44
+ {'timestamp': '2026-04-25T20:39:59.741888', 'user': 'user3', 'action': 'action3', 'endpoint': '/endpoint3', 'method': 'POST', 'status_code': 200, 'details': {}}
45
+ {'timestamp': '2026-04-25T20:39:59.742387', 'user': 'user4', 'action': 'action4', 'endpoint': '/endpoint4', 'method': 'POST', 'status_code': 200, 'details': {}}