Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ _build
venv
.vscode
.coverage
cov.xml
api-saagie.iml
out/
.env
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pip install saagieapi==<version>
| >= 2023.05 | >= 2.10.0 |
| >= 2024.01 | >= 2.11.0 |
| >= 2024.02 | >= 2.12.0 |
| >= 2024.03 | >= 2.13.0 |
| >= 2024.05 | >= 2.14.0 |

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "saagieapi"
version = "2.13.0"
version = "2.14.0"
description = "Python API to interact with Saagie"
authors = ["Saagie"]
license = "GLWTPL"
Expand Down
71 changes: 31 additions & 40 deletions saagieapi/apps/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,17 +1467,19 @@ def count_history_statuses(self, history_id, version_number, start_time):

def get_logs(
self,
project_id: str,
app_id: str,
app_execution_id: str,
limit: int = None,
skip: int = None,
log_stream: str = None,
start_at: str = None,
):
"""Get logs of the app

Parameters
----------
project_id : str
UUID of your project
app_id : str
UUID of your app
app_execution_id : str
Expand All @@ -1490,9 +1492,6 @@ def get_logs(
Stream of logs to follow. Values accepted :
[ENVVARS_STDOUT, ENVVARS_STDERR, ORCHESTRATION_STDOUT, ORCHESTRATION_STDERR, STDERR, STDOUT]
By default, all the streams are retrieved
start_at: str, optional
Get logs since a specific datetime.
Following formats accepted : "2024-04-09 10:00:00" and "2024-04-09T10:00:00"

Returns
-------
Expand All @@ -1508,43 +1507,35 @@ def get_logs(
... skip=5,
... start_at="2024-04-09 10:00:00"
... )

{
"appLogs": {
"count": 25,
"content": [
{
"index": 5,
"value": "[I 2024-04-09 13:38:36.982 ServerApp] jupyterlab_git | extension was successfully linked.",
"containerId": "d7104fa7371c5ed6ef540fa8b0620a654a0e02c57136e29f0fcc03d16e36d74f",
"stream": "STDERR",
"recordAt": "2024-04-09T13:38:36.982473892Z"
},
{
"index": 6,
"value": "[W 2024-04-09 13:38:36.987 NotebookApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.",
"containerId": "d7104fa7371c5ed6ef540fa8b0620a654a0e02c57136e29f0fcc03d16e36d74f",
"stream": "STDERR",
"recordAt": "2024-04-09T13:38:36.987400105Z"
}
]
"logs": [
{
"index": 0,
"stream": "STDERR",
"time": "2024-12-11T14:27:42.858298425Z",
"value": "[I 2024-04-09 13:38:36.982 ServerApp] jupyterlab_git | extension was successfully linked.",
},
{
"index": 1,
"stream": "STDERR",
"time": "2024-12-11T14:27:42.859697094Z",
"value": "AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.4.3.20. Set the 'ServerName' directive globally to suppress this message"
}
],
"limit": 10000,
"total": 5,
"order": "asc",
"source": "elastic"
}
"""
params = {
"appId": app_id,
"appExecutionId": app_execution_id,
}

if limit:
params["limit"] = limit

if skip:
params["skip"] = skip

if log_stream:
params["stream"] = log_stream

if start_at:
params["recordAt"] = start_at

return self.saagie_api.client.execute(query=gql(GQL_GET_APP_LOG), variable_values=params)
if limit is None:
limit = 10000
if skip is None:
skip = 0
if log_stream is None:
log_stream = "ENVVARS_STDOUT,ENVVARS_STDERR,ORCHESTRATION_STDOUT,ORCHESTRATION_STDERR,STDERR,STDOUT"
url = f"{self.saagie_api.url_saagie}log-proxy/api/logs/{self.saagie_api.realm}/platform/{self.saagie_api.platform}/project/{project_id}/app_execution/{app_execution_id}?limit={limit}&skip={skip}&streams={log_stream}"
response = self.saagie_api.request_client.send(method="GET", url=url, raise_for_status=True)

return response.json()
16 changes: 0 additions & 16 deletions saagieapi/apps/gql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,19 +452,3 @@
countAppHistoryStatuses(appHistoryId: $appHistoryId, versionNumber: $versionNumber, startTime: $startTime)
}
"""

GQL_GET_APP_LOG = """
query appLogs($appId: UUID!, $appExecutionId: UUID!, $limit: Int, $skip: Int, $stream: LogStream, $recordAt: String) {
appLogs(appId: $appId, appExecutionId: $appExecutionId, limit: $limit, skip: $skip, stream: $stream, recordAt: $recordAt)
{
count
content {
index
value
containerId
stream
recordAt
}
}
}
"""
56 changes: 0 additions & 56 deletions saagieapi/gql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,59 +132,3 @@
)
}
"""

GQL_COUNT_CONDITION_LOGS = """
query conditionPipelineCountFilteredLogs($conditionInstanceId: UUID!,
$projectID: UUID!,
$streams: [LogStream]!) {
conditionPipelineCountFilteredLogs (
conditionInstanceID: $conditionInstanceId,
projectID: $projectID,
streams: $streams
)
}
"""

GQL_GET_CONDITION_LOGS_BY_CONDITION = """
query conditionPipelineByNodeIdFilteredLogs($pipelineInstanceID: UUID!,
$conditionNodeID: UUID!,
$projectID: UUID!,
$streams: [LogStream]!) {
conditionPipelineByNodeIdFilteredLogs(
pipelineInstanceID: $pipelineInstanceID,
conditionNodeID: $conditionNodeID,
projectID: $projectID,
streams: $streams
) {
count
content {
index
value
stream
}
}
}
"""

GQL_GET_CONDITION_LOGS_BY_INSTANCE = """
query conditionPipelineFilteredLogs($conditionInstanceId: UUID!,
$projectId: UUID!,
$limit: Int,
$skip: Int,
$streams: [LogStream]!) {
conditionPipelineFilteredLogs(
conditionInstanceID: $conditionInstanceId,
projectID:$projectId,
limit: $limit,
skip: $skip,
streams: $streams
) {
count
content {
index
value
stream
}
}
}
"""
Loading
Loading