https://dagster.io/ logo
Title
g

Gillian Sharer

10/05/2021, 4:42 PM
Hello, I'm just learning Dagster. I have a pipeline that runs a script that sends log messages to stdout. When I run it without celery, I see these log messages in the Dagit run stdout for the solid. But when I run it using celery, the messages print out to the window where I'm running the celery worker and Dagit doesn't see it. How can I preserve and access these messages when running my pipeline using celery?
c

claire

10/06/2021, 4:36 PM
Hi Gillian, this guide might be helpful to you: https://docs.dagster.io/deployment/guides/celery#execute-on-celery If you run the celery worker in the same directory as you saved the pipeline file, celery logs should populate in Dagit
d

Dan Stoner

10/06/2021, 4:54 PM
@claire I have reproduced the problem @Gillian Sharer reported, with celery executor (and the pipeline declaring
celery_mode_defs
as indicated in that documentation), I get a directory full of
0
byte files.
instead of actual logs
ls -latr dagster_home/storage/c2345b9e-be27-420c-88d1-ab0a5a17bef1/compute_logs
total 0
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_dates.out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_archive_cache.out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_mustang_cache.out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_dates.err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_archive_cache.err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_mustang_cache.err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_station_list.out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_station_list.err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_archive_cache.complete
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_dates.complete
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 create_mustang_cache.complete
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 get_station_list.complete
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ABPO].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ALE].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ABPO].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ALE].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ARTI].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ARTI].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ASCN].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ASCN].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BORK].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BORK].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_CMLA].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BORG].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_CMLA].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BFO].out
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BORG].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_BFO].err
-rw-r--r--   1 dstoner  staff     0 Oct  5 19:12 run_metrics_for_one[II_ASCN].complete
...
"No output" in dagit
j

johann

10/06/2021, 5:04 PM
Hi Dan, have you configured a ComputeLogManager on your instance?
d

Dan Stoner

10/06/2021, 5:05 PM
Have not touched that since the default is supposed to be "local files" or some such thing
I still don't have a good handle on the terminology and boundaries for all these configurations. repository vs workspace vs instance. 🤯
If there is a diagram somewhere, would appreciate seeing it.
j

johann

10/06/2021, 5:14 PM
We hear you on the configuration complexity! Definitely something that’s on our mind, and we appreciate any feedback.
Let me jump in to the specific issue first, then we could circle back to the overall system question? For this issue, are the celery workers running on the same host as Dagit? As in, they have access to the same filesystem?
Configuring compute log storage is the solution when this isn’t the case, which is why I brought that up. But it seems like you’re on one box? https://docs.dagster.io/deployment/dagster-instance#compute-log-storage
d

Dan Stoner

10/06/2021, 5:16 PM
yes, on the same system (our development laptops)
j

johann

10/06/2021, 5:16 PM
Got it
And just to be concrete: • this is with the DefaultRunLauncher? • When using inprocess or multiprocess executors, the logs show up • When using the celery executor, they don’t
And the Mode you’re using for celery has the same logging configuration?
d

Dan Stoner

10/06/2021, 5:20 PM
This is where having config scattered everywhere makes answering your questions a challenge.
When using inprocess or multiprocess executors, the logs show up
YES
When using the celery executor, they don’t
YES
I was going to say we switched to the Queued Run Launcher in order to use celery, but I'm looking and that doesn't seem to be a thing.
Pretty sure if I didn't need to change from defaults I didn't.
Ah. We had to use
QueuedRunCoordinator
in order to use Celery
I searched my code repo for "RunLauncher" and didn't find anything, so I assume we are using the default.
j

johann

10/06/2021, 5:24 PM
👍
Ah. We had to use 
QueuedRunCoordinator
 in order to use Celery
I don’t believe this is a requirement, I’m curious what you ran in to
d

Dan Stoner

10/06/2021, 5:28 PM
Oh, maybe I needed concurrency limits to prevent Celery from destroying my machine.
j

johann

10/06/2021, 5:28 PM
Got it
d

Dan Stoner

10/06/2021, 5:29 PM
but I sorta feel like no tasks get submitted to the broker without changing the Run Coordinator
j

johann

10/06/2021, 5:29 PM
When you ran pipeline without celery, did you have a ModeDefinition defined? Or was it just defaults
d

Dan Stoner

10/06/2021, 5:34 PM
when not actually using celery executor, it works whether ModeDefinition is defined or not. 1. Initially we didn't have ModeDefinition at all (no celery, could see logs) 2. added ModeDefinition for celery, could not see logs 3. toggled the executor to multiprocess but didn't change the pipeline def so it still has ModeDefinition and can still see the logs
j

johann

10/06/2021, 5:35 PM
That’s helpful, thanks
d

Dan Stoner

10/06/2021, 5:35 PM
Having to "paste config into the playground" is... annoying. I wish I knew where to actually put some of this kind of config.
execution:
  multiprocess:
    config:
      max_concurrent: 3
since to test I want to toggle that back to the Celery executor, but that isn't stored anywhere in config management
Not sure what part of the system created the
.out
files for those jobs (the
0
byte ones I mentioned). Celery or the job manager?
j

johann

10/06/2021, 5:47 PM
Having to “paste config into the playground” is... annoying
Currently, those can be stored in code in PresetDefinitions (under run config). We’re very aware that there are a bunch of nouns and concepts here, and in a few weeks we’ll be releasing a revamp that seeks to simplify things https://docs.dagster.io/_apidocs/experimental
Not sure what part of the system created the 
.out
 files for those jobs (the 
0
 byte ones I mentioned).  Celery or the job manager?
That would be Dagster’s compute log manager.
@prha could I put this on your radar to try to repro? (Logs not showing up with celery executor and local compute logs)
p

prha

10/06/2021, 5:52 PM
@Dagster Bot issue Compute logs empty for runs executed with the celery executor
d

Dagster Bot

10/06/2021, 5:52 PM
d

Dan Stoner

10/06/2021, 5:52 PM
One more thing, I believe most/all of the job output is STDOUT from a Docker container...
subprocess.run(["docker","run", ...])
^^^ I will add this to the github issue
also, nice Slack bot!
It appears that the only thing needed to break capture of Celery logs is this import statement:
import subprocess
(I added this to the github issue)
j

johann

10/06/2021, 9:09 PM
Wow, bizarre
But this import doesn’t break it with inprocess/multiprocess executor?
d

Dan Stoner

10/06/2021, 9:11 PM
I will verify. It also seems that any time the code changes the celery worker needs to be restarted.
j

johann

10/06/2021, 9:12 PM
That’s correct, since the celery workers run the code in process. Ideally celery wouldn’t be part of your dev flow so you could avoid that, but it would also be possible to setup hot reload that restarts the workers for you.
d

Dan Stoner

10/06/2021, 9:19 PM
I might be retracting my bizarre statement.
I now think the most specific description is that output from print statements (aka STDOUT) from a job executed in celery is lost (not captured). Period.
Confirmed when running exactly the same in Playground except one change of removing execution: celery config, I get the expected outputs in a captured log.