Skip to content

Commit

Permalink
🎨 Format - ran black and format-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Dec 7, 2023
1 parent 877be34 commit 253029a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
57 changes: 30 additions & 27 deletions agenta-backend/agenta_backend/services/logs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@


def retrieve_cloudwatch_logs(function_app_id: str):
log_group_name = f"/aws/lambda/app-{function_app_id}"

# Describe log streams to get the newest log stream
response = client.describe_log_streams(
logGroupName=log_group_name, orderBy="lastEventTimestamp", descending=True, limit=1
)

if "logStreams" in response and len(response["logStreams"]) > 0:
newest_log_stream = response["logStreams"][0]["logStreamName"]

# Get log events of the newest log stream
log_events_response = client.get_log_events(
logGroupName=log_group_name, logStreamName=newest_log_stream
)
if "events" in log_events_response:
response_data = {}
list_of_events_messages = []
for event in log_events_response["events"]:
list_of_events_messages.append(event["message"])

response_data["message"] = "Log events found in the newest log stream"
response_data["data"] = list_of_events_messages
return response_data
else:
return "No log events found in the newest log stream"
else:
return "No log streams found in the log group."
log_group_name = f"/aws/lambda/app-{function_app_id}"

# Describe log streams to get the newest log stream
response = client.describe_log_streams(
logGroupName=log_group_name,
orderBy="lastEventTimestamp",
descending=True,
limit=1,
)

if "logStreams" in response and len(response["logStreams"]) > 0:
newest_log_stream = response["logStreams"][0]["logStreamName"]

# Get log events of the newest log stream
log_events_response = client.get_log_events(
logGroupName=log_group_name, logStreamName=newest_log_stream
)
if "events" in log_events_response:
response_data = {}
list_of_events_messages = []
for event in log_events_response["events"]:
list_of_events_messages.append(event["message"])

response_data["message"] = "Log events found in the newest log stream"
response_data["data"] = list_of_events_messages
return response_data
else:
return "No log events found in the newest log stream"
else:
return "No log streams found in the log group."
4 changes: 3 additions & 1 deletion agenta-cli/agenta/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ def retrieve_user_id(host: str, api_key: Optional[str] = None) -> str:
raise APIRequestError(f"Request failed: {str(e)}")


def retrieve_variant_logs(variant_id: str, api_key: Optional[str], host: str, version: str = "cloud"):
def retrieve_variant_logs(
variant_id: str, api_key: Optional[str], host: str, version: str = "cloud"
):
"""Retrieve variant logs from the server.
Args:
Expand Down
14 changes: 8 additions & 6 deletions agenta-web/src/components/Playground/ViewNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const ViewNavigation: React.FC<Props> = ({
if (isError) {
let variantDesignator = variant.templateVariantName
let appName = currentApp?.app_name || ""
let imageName = `agentaai/${(appName).toLowerCase()}_`
let imageName = `agentaai/${appName.toLowerCase()}_`

if (!variantDesignator || variantDesignator === "") {
variantDesignator = variant.variantName
Expand Down Expand Up @@ -175,16 +175,18 @@ const ViewNavigation: React.FC<Props> = ({
accessible.
</li>
<li>
Check if the Docker container for the variant {variantDesignator} is active by running the following command in your terminal:
Check if the Docker container for the variant {variantDesignator} is
active by running the following command in your terminal:
<pre>docker logs {containerName} --tail 50 -f</pre>
Running the above command will enable you to continuously stream the container logs in real-time as they are generated.
Running the above command will enable you to continuously stream the
container logs in real-time as they are generated.
</li>
</ul>
<p>
{" "}
In case the docker container is not running, please check the Docker logs to understand the issue.
Most of the time, it is due to missing requirements.
Also, please attempt restarting it (using cli or docker
In case the docker container is not running, please check the Docker
logs to understand the issue. Most of the time, it is due to missing
requirements. Also, please attempt restarting it (using cli or docker
desktop).
</p>
<p>
Expand Down

0 comments on commit 253029a

Please sign in to comment.