Skip to content

Commit 6a84126

Browse files
freddyaboultonmodal-bot
authored andcommitted
[PY-SDK] Remove App._logs (#53365)
GitOrigin-RevId: 378237f54278e9aa39c2077b2c41573efdb86f8f
1 parent 7cc4fb5 commit 6a84126

2 files changed

Lines changed: 3 additions & 30 deletions

File tree

py/modal/app.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,33 +1579,6 @@ async def get_tags(self, *, client: _Client | None = None) -> dict[str, str]:
15791579
resp = await client.stub.AppGetTags(req)
15801580
return dict(resp.tags)
15811581

1582-
async def _logs(self, client: _Client | None = None) -> AsyncGenerator[str, None]:
1583-
"""Stream logs from the app.
1584-
1585-
This method is considered private and its interface may change - use at your own risk!
1586-
"""
1587-
if not self._app_id:
1588-
raise InvalidError("`app._logs` requires a running/stopped app.")
1589-
1590-
client = client or self._client or await _Client.from_env()
1591-
1592-
last_log_batch_entry_id: str | None = None
1593-
while True:
1594-
request = api_pb2.AppGetLogsRequest(
1595-
app_id=self._app_id,
1596-
timeout=55,
1597-
last_entry_id=last_log_batch_entry_id,
1598-
)
1599-
async for log_batch in client.stub.AppGetLogs.unary_stream(request):
1600-
if log_batch.entry_id:
1601-
# log_batch entry_id is empty for fd="server" messages from AppGetLogs
1602-
last_log_batch_entry_id = log_batch.entry_id
1603-
if log_batch.app_done:
1604-
return
1605-
for log in log_batch.items:
1606-
if log.data:
1607-
yield log.data
1608-
16091582
@classmethod
16101583
def _get_container_app(cls) -> "_App | None":
16111584
"""Returns the `App` running inside a container.
@@ -1621,7 +1594,7 @@ def _reset_container_app(cls):
16211594
async def _get_log_query_data(self) -> _LogQueryData:
16221595
"""Get the data needed to query logs for this app."""
16231596
if not self._app_id:
1624-
raise InvalidError("`app._logs` requires a running/stopped app.")
1597+
raise InvalidError("`app.logs` requires a running/stopped app.")
16251598
client = self._client or await _Client.from_env()
16261599
filters = LogsFilters()
16271600
return _LogQueryData(client=client, app_id=self._app_id, filters=filters, source_object_id=self._app_id)

py/test/app_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ def test_non_string_app_name():
358358
App(Image.debian_slim()) # type: ignore
359359

360360

361-
def test_app_logs(servicer, client):
361+
def test_app_logs(servicer, client, set_env_client):
362362
app = App(include_source=False)
363363
f = app.function()(dummy)
364364

365365
with app.run(client=client):
366366
f.remote()
367367

368-
logs = [data for data in app._logs(client=client)]
368+
logs = [entry.message for entry in app.logs.stream()]
369369
assert logs == ["hello, world (1)\n"]
370370

371371

0 commit comments

Comments
 (0)