Skip to content

Commit 8543284

Browse files
anth-volkclaude
andcommitted
Add modal.enable_output() for log streaming from deployed functions
Function.from_name().remote() doesn't stream container logs by default. Wrap all calls in modal.enable_output() context manager to stream stdout/stderr from Modal containers to GH Actions logs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent abcc643 commit 8543284

1 file changed

Lines changed: 47 additions & 40 deletions

File tree

.github/workflows/push.yaml

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ jobs:
5656
run: |
5757
python -c "
5858
import modal
59-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
60-
result = fn.remote(
61-
script_name='download_prerequisites',
62-
branch='${{ github.ref_name }}',
63-
)
59+
with modal.enable_output():
60+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
61+
result = fn.remote(
62+
script_name='download_prerequisites',
63+
branch='${{ github.ref_name }}',
64+
)
6465
print(result)
6566
"
6667
@@ -85,12 +86,13 @@ jobs:
8586
run: |
8687
python -c "
8788
import modal
88-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
89-
result = fn.remote(
90-
script_name='${{ matrix.dataset }}',
91-
branch='${{ github.ref_name }}',
92-
run_tests=True,
93-
)
89+
with modal.enable_output():
90+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
91+
result = fn.remote(
92+
script_name='${{ matrix.dataset }}',
93+
branch='${{ github.ref_name }}',
94+
run_tests=True,
95+
)
9496
print(result)
9597
"
9698
@@ -115,12 +117,13 @@ jobs:
115117
run: |
116118
python -c "
117119
import modal
118-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
119-
result = fn.remote(
120-
script_name='${{ matrix.dataset }}',
121-
branch='${{ github.ref_name }}',
122-
run_tests=True,
123-
)
120+
with modal.enable_output():
121+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
122+
result = fn.remote(
123+
script_name='${{ matrix.dataset }}',
124+
branch='${{ github.ref_name }}',
125+
run_tests=True,
126+
)
124127
print(result)
125128
"
126129
@@ -141,12 +144,13 @@ jobs:
141144
run: |
142145
python -c "
143146
import modal
144-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
145-
result = fn.remote(
146-
script_name='extended_cps',
147-
branch='${{ github.ref_name }}',
148-
run_tests=True,
149-
)
147+
with modal.enable_output():
148+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
149+
result = fn.remote(
150+
script_name='extended_cps',
151+
branch='${{ github.ref_name }}',
152+
run_tests=True,
153+
)
150154
print(result)
151155
"
152156
@@ -171,12 +175,13 @@ jobs:
171175
run: |
172176
python -c "
173177
import modal
174-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
175-
result = fn.remote(
176-
script_name='${{ matrix.dataset }}',
177-
branch='${{ github.ref_name }}',
178-
run_tests=True,
179-
)
178+
with modal.enable_output():
179+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
180+
result = fn.remote(
181+
script_name='${{ matrix.dataset }}',
182+
branch='${{ github.ref_name }}',
183+
run_tests=True,
184+
)
180185
print(result)
181186
"
182187
@@ -201,12 +206,13 @@ jobs:
201206
run: |
202207
python -c "
203208
import modal
204-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
205-
result = fn.remote(
206-
script_name='${{ matrix.dataset }}',
207-
branch='${{ github.ref_name }}',
208-
run_tests=True,
209-
)
209+
with modal.enable_output():
210+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script')
211+
result = fn.remote(
212+
script_name='${{ matrix.dataset }}',
213+
branch='${{ github.ref_name }}',
214+
run_tests=True,
215+
)
210216
print(result)
211217
"
212218
@@ -233,11 +239,12 @@ jobs:
233239
run: |
234240
python -c "
235241
import modal
236-
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_integration_test')
237-
result = fn.remote(
238-
test_path='${{ matrix.test }}',
239-
branch='${{ github.ref_name }}',
240-
)
242+
with modal.enable_output():
243+
fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_integration_test')
244+
result = fn.remote(
245+
test_path='${{ matrix.test }}',
246+
branch='${{ github.ref_name }}',
247+
)
241248
print(result)
242249
"
243250

0 commit comments

Comments
 (0)