Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Airflow Workflow Submission from Command-line #29

Merged
merged 5 commits into from
Jul 2, 2024

Conversation

gadorlhiac
Copy link
Collaborator

@gadorlhiac gadorlhiac commented Jul 1, 2024

Description

This PR adds support for submitting complete workflows (Airflow DAGs) from the command-line. Previously workflows needed to be submitted from the ARP only, while each stage of a workflow could be submitted manually from a terminal.

Checklist

  • Support direct Python running from terminal by requesting authentication tokens. This requires keeping the process open (or running in background).
  • Support SLURM submission from terminal by requesting authentication tokens.
  • Documentation update for new submission mode.

PR Type:

  • New feature/Enhancement

Address issues:

  • NA

Testing

Tested the branch to confirm working, e.g.

SLURM Submission

[dorlhiac@sdfiana003 /sdf/scratch/users/d/dorlhiac]$> ./lute/launch_scripts/submit_launch_airflow.sh /sdf/scratch/users/d/dorlhiac/lute/launch_scripts/launch_airflow.py -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data
/sdf/scratch/users/d/dorlhiac/lute/launch_scripts/launch_airflow.py -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data
Running /sdf/group/lcls/ds/tools/lute/lute_launcher /sdf/scratch/users/d/dorlhiac/lute/launch_scripts/launch_airflow.py -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data with --partition=milano --account=lcls:data --ntasks=1
Submitted batch job 51572712
[dorlhiac@sdfiana003 /sdf/scratch/users/d/dorlhiac]$> cat slurm-51572712.out
Options: -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data
Running /sdf/scratch/users/d/dorlhiac/lute/launch_scripts/launch_airflow.py -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data
INFO:Launch_Airflow:Submitted DAG (Workflow): test
DAG_RUN_ID: 05320977-1b31-4873-ada0-2a8db3b527c6
INFO:Launch_Airflow:DAG is queued
INFO:Launch_Airflow:Contains Managed Tasks (alphabetical, not execution order):
	- BinaryErrTester,
	- BinaryTester,
	- ReadTester,
	- SocketTester,
	- Tester,
	- WriteTester
INFO:Launch_Airflow:Tester state: running
INFO:Launch_Airflow:SocketTester state: running
INFO:Launch_Airflow:BinaryErrTester state: running
INFO:Launch_Airflow:BinaryTester state: running
INFO:Launch_Airflow:Providing logs for Tester
--------------------------------------------------
INFO:lute.execution.executor:Sourcing file /sdf/group/lcls/ds/tools/ccp4-8.0/bin/ccp4.setup-sh
INFO:lute.execution.executor:Sourcing file /sdf/group/lcls/ds/tools/ccp4-8.0/bin/ccp4.setup-sh
DEBUG:lute.execution.executor:Cannot set result from TaskParameters. `set_result` not specified!
INFO:lute.execution.executor:Executor: Test started
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/prjxrai22/get_counters HTTP/1.1" 200 28
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/replace_counters/prjxrai22/73d36584-bd1a-48c0-8dbc-b4228eabeeb4 HTTP/1.1" 200 94
INFO:lute.execution.executor:lute_config=AnalysisHeader(title='LUTE Task Configuration', experiment='EXPL10000', run=1, date='2023/10/25', lute_version=0.1, task_timeout=600, work_dir='/sdf/scratch/users/d/dorlhiac') float_var=0.01 str_var='test' compound_var=CompoundVar(int_var=10, dict_var={'a': 'b'}) throw_error=False
INFO:lute.execution.executor:Test message 0
INFO:lute.execution.executor:Test message 1
INFO:lute.execution.executor:Test message 2
INFO:lute.execution.executor:Test message 3
INFO:lute.execution.executor:Test message 4
INFO:lute.execution.executor:Test message 5
INFO:lute.execution.executor:Test message 6
INFO:lute.execution.executor:Test message 7
INFO:lute.execution.executor:Test message 8
INFO:lute.execution.executor:Test message 9
INFO:lute.execution.executor:Test Finished.
INFO:lute.execution.executor:TaskStatus.COMPLETED
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/prjxrai22/get_counters HTTP/1.1" 200 113
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/replace_counters/prjxrai22/73d36584-bd1a-48c0-8dbc-b4228eabeeb4 HTTP/1.1" 200 146
INFO:lute.execution.executor:TaskResult(task_name='Test', task_status=<TaskStatus.COMPLETED: 2>, summary='Test Finished.', payload='', impl_schemas=None)
DEBUG:lute.io._sqlite:_make_task_table[CREATE]: CREATE TABLE IF NOT EXISTS Test(id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, gen_cfg_id INTEGER, exec_cfg_id INTEGER, "float_var" REAL, "str_var" TEXT, "compound_var.int_var" INTEGER, "compound_var.dict_var.a" TEXT, "throw_error" INTEGER, "result.task_status" TEXT, "result.summary" TEXT, "result.payload" BLOB, "result.impl_schemas" TEXT, valid_flag INTEGER)
DEBUG:root:_gen_cfg_table_entry: Rows matching title LIKE 'LUTE Task Configuration' AND experiment LIKE 'EXPL10000' AND run LIKE '1' AND date LIKE '2023/10/25' AND lute_version LIKE '0.1' AND task_timeout LIKE '600': [(1,)]
DEBUG:root:_exec_cfg_table_entry: No matching rows - adding new row: 12
DEBUG:lute.io._sqlite:_add_task_entry: ['"gen_cfg_id"', '"exec_cfg_id"', '"float_var"', '"str_var"', '"compound_var.int_var"', '"compound_var.dict_var.a"', '"throw_error"', '"result.task_status"', '"result.summary"', '"result.payload"', '"result.impl_schemas"', '"valid_flag"']
		[1, 12, 0.01, 'test', 10, 'b', False, 'COMPLETED', 'Test Finished.', '', None, 1]

--------------------------------------------------
INFO:Launch_Airflow:End of logs for Tester
# ... CONTINUES ....

Direct Python Submission

[dorlhiac@sdfiana003 /sdf/scratch/users/d/dorlhiac]$> python -B lute/launch_scripts/launch_airflow.py -e prjxrai22 -r 1 -c /sdf/scratch/users/d/dorlhiac/lute/config/test.yaml --debug --partition=milano --account=lcls:data
INFO:Launch_Airflow:Submitted DAG (Workflow): test
DAG_RUN_ID: 67311522-872e-422f-8c0d-76e84dc371a7
INFO:Launch_Airflow:DAG is queued
INFO:Launch_Airflow:Contains Managed Tasks (alphabetical, not execution order):
	- BinaryErrTester,
	- BinaryTester,
	- ReadTester,
	- SocketTester,
	- Tester,
	- WriteTester
INFO:Launch_Airflow:Tester state: queued
INFO:Launch_Airflow:BinaryErrTester state: queued
INFO:Launch_Airflow:BinaryTester state: queued
INFO:Launch_Airflow:SocketTester state: queued
INFO:Launch_Airflow:Providing logs for Tester
--------------------------------------------------
INFO:lute.execution.executor:Sourcing file /sdf/group/lcls/ds/tools/ccp4-8.0/bin/ccp4.setup-sh
INFO:lute.execution.executor:Sourcing file /sdf/group/lcls/ds/tools/ccp4-8.0/bin/ccp4.setup-sh
DEBUG:lute.execution.executor:Cannot set result from TaskParameters. `set_result` not specified!
INFO:lute.execution.executor:Executor: Test started
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/prjxrai22/get_counters HTTP/1.1" 200 28
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/replace_counters/prjxrai22/75d77c03-a99c-472a-8948-e02f66787dbd HTTP/1.1" 200 94
INFO:lute.execution.executor:lute_config=AnalysisHeader(title='LUTE Task Configuration', experiment='EXPL10000', run=1, date='2023/10/25', lute_version=0.1, task_timeout=600, work_dir='/sdf/scratch/users/d/dorlhiac') float_var=0.01 str_var='test' compound_var=CompoundVar(int_var=10, dict_var={'a': 'b'}) throw_error=False
INFO:lute.execution.executor:Test message 0
INFO:lute.execution.executor:Test message 1
INFO:lute.execution.executor:Test message 2
INFO:lute.execution.executor:Test message 3
INFO:lute.execution.executor:Test message 4
INFO:lute.execution.executor:Test message 5
INFO:lute.execution.executor:Test message 6
INFO:lute.execution.executor:Test message 7
INFO:lute.execution.executor:Test message 8
INFO:lute.execution.executor:Test message 9
INFO:lute.execution.executor:Test Finished.
INFO:lute.execution.executor:TaskStatus.COMPLETED
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/prjxrai22/get_counters HTTP/1.1" 200 113
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): psdm.slac.stanford.edu:443
DEBUG:urllib3.connectionpool:https://psdm.slac.stanford.edu:443 "POST /arps3dfjid/jid/ws/replace_counters/prjxrai22/75d77c03-a99c-472a-8948-e02f66787dbd HTTP/1.1" 200 146
INFO:lute.execution.executor:TaskResult(task_name='Test', task_status=<TaskStatus.COMPLETED: 2>, summary='Test Finished.', payload='', impl_schemas=None)
DEBUG:lute.io._sqlite:_make_task_table[CREATE]: CREATE TABLE IF NOT EXISTS Test(id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, gen_cfg_id INTEGER, exec_cfg_id INTEGER, "float_var" REAL, "str_var" TEXT, "compound_var.int_var" INTEGER, "compound_var.dict_var.a" TEXT, "throw_error" INTEGER, "result.task_status" TEXT, "result.summary" TEXT, "result.payload" BLOB, "result.impl_schemas" TEXT, valid_flag INTEGER)
DEBUG:root:_gen_cfg_table_entry: No matching rows - adding new row: 1
DEBUG:root:_exec_cfg_table_entry: No matching rows - adding new row: 1
DEBUG:lute.io._sqlite:_add_task_entry: ['"gen_cfg_id"', '"exec_cfg_id"', '"float_var"', '"str_var"', '"compound_var.int_var"', '"compound_var.dict_var.a"', '"throw_error"', '"result.task_status"', '"result.summary"', '"result.payload"', '"result.impl_schemas"', '"valid_flag"']
		[1, 1, 0.01, 'test', 10, 'b', False, 'COMPLETED', 'Test Finished.', '', None, 1]

--------------------------------------------------
INFO:Launch_Airflow:End of logs for Tester
INFO:Launch_Airflow:WriteTester state: queued

Screenshots

@gadorlhiac gadorlhiac requested a review from valmar July 1, 2024 16:44
@gadorlhiac gadorlhiac marked this pull request as ready for review July 1, 2024 16:44
Copy link
Contributor

@valmar valmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think with Kerberos, that's the best we can do!

@gadorlhiac gadorlhiac merged commit dc037e0 into slac-lcls:dev Jul 2, 2024
1 check passed
@gadorlhiac gadorlhiac deleted the ENH/airflow_terminal branch July 2, 2024 01:47
gadorlhiac added a commit to gadorlhiac/lute_dorlhiac that referenced this pull request Jul 30, 2024
* ENH ARP token for command-line workflow submission.

* ENH Support launching Airflow through the SLURM submission script.

* BUG Correct the filename to remove duplicate Kerberos credentials

* DOC Update documentation for worflow submission from command-line

* BUG Only copy Kerberos credentials in bash script if Authorization undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants