Repository navigation
Conversation
|
I wonder if we should make the config multi-state; |
|
@uranusjr That's a good idea. I'll do that. |
667b74b to
566f2e1
Compare
|
|
||
| COLORED_FORMATTER_CLASS: str = conf.get_mandatory_value('logging', 'COLORED_FORMATTER_CLASS') | ||
|
|
||
| DAG_PROCESSOR_LOG_TARGET: bool = conf.get_mandatory_value('scheduler', 'DAG_PROCESSOR_LOG_TARGET') |
There was a problem hiding this comment.
Should this belong to scheduler or logging?
There was a problem hiding this comment.
Yeah I'm uncertain of the convention here. It seems like logging makes more sense, however, when the logs are sent to files, the proper directory is defined under scheduler.child_process_log_directory. That's why I put it in scheduler.
With that in mind, which do you think makes more sense?
There was a problem hiding this comment.
I’m not sure either, things are a bit all over the place, there’s even a DAG-processor-related config in core. I would probably put it under logging that’s where most scheduler-related logging configs go.
There was a problem hiding this comment.
Ok cool, that works for me. Thanks TP!
There was a problem hiding this comment.
We tried to consolidate all the logging configs into the logging section a couple of years back: 046b36f
So that's the goal at least, other configs are marked for deprecation
airflow/airflow/configuration.py
Lines 173 to 196 in d82436b
There was a problem hiding this comment.
so all the logging related configs should be moved there.
| DAG_PROCESSOR_LOG_TARGET: bool = conf.get_mandatory_value('scheduler', 'DAG_PROCESSOR_LOG_TARGET') | |
| DAG_PROCESSOR_LOG_TARGET: bool = conf.get_mandatory_value('logging', 'DAG_PROCESSOR_LOG_TARGET') |
| - name: dag_processor_log_target | ||
| description: Where to send dag parser logs. If "file", | ||
| logs are sent to log files defined by child_process_log_directory. | ||
| version_added: 2.3.4 |
There was a problem hiding this comment.
Are we planning to include this in 2.3.4?
| if DAG_PROCESSOR_LOG_TARGET == "stdout": | ||
| with Stats.timer() as timer: | ||
| _handle_dag_file_processing() | ||
| else: |
There was a problem hiding this comment.
Some test coverage around this flow would be good :)
There was a problem hiding this comment.
Oooof. Alright I'll think out how to do that.
There was a problem hiding this comment.
@kaxil ok running into some issue with testing this. Can you suggest an effective way to test something dependent on the internal behavior of the processor? It appears that no existing tests actually do this.
This is the basic structure of the test I'm adding to test_processor.py.
@conf_vars({("logging", "dag_processor_log_target"): "file"})
def test_stuff(self):
"""
Test that the dag file processor does not call the sla miss callback when
given an invalid sla
"""
with create_session() as session:
processor = DagFileProcessorProcess('abc.txt', False, ["fake_dag_id"], [])
# processor.start()
start_method = processor._get_multiprocessing_start_method()
context = multiprocessing.get_context(start_method)
_parent_channel, _child_channel = context.Pipe(duplex=False)
processor._run_file_processor(
result_channel=_child_channel,
parent_channel=_parent_channel,
file_path='abc.txt',
pickle_dags=False,
dag_ids=['fake_dag_ids'],
thread_name='DagFileProcessor0',
callback_requests=[],
)
_child_channel.close()
del _child_channelThese tests consistently fail with
ERROR tests/dag_processing/test_processor.py::TestDagFileProcessor::test_stuff - RuntimeError: Session must be set before!
FAILED tests/dag_processing/test_processor.py::TestDagFileProcessor::test_stuff - BrokenPipeError: [Errno 32] Broken pipe
I've attempted to address both of these issues without much luck. I've also looked into both going to a higher level to test (Instantiating DagFileProcessorAgent, which creates the DagFileProcessorProcess class), as well as mocking out internal methods called by DagFileProcessorProcess._run_file_processor, but this seems like a brittle approach, at best.
There was a problem hiding this comment.
Mocking is fine, the only thing I want to test is the if-else flow tbh :)
No description provided.