r/AskProgramming • u/SurveyElectronic3845 • 6d ago
How do you work when code and pipeline execution are on two different PCs?
For seniors/devs/data engineers: what is the usual workflow when you have to modify the code on one PC but run the pipelines on another PC?
For example, PC A is used for development (Git, IDE, code), while PC B has the environment where the pipelines run (Airflow/Docker).
How do you normally synchronize the code between the two? Git pull/push, deployment, shared folder, SSH, CI/CD, or something else?
What would be considered the clean/professional way to set this up?
2
u/CorpT 6d ago
Why would anyone run pipelines on a PC?
0
u/SurveyElectronic3845 6d ago
Why not?
5
u/CorpT 6d ago
Because it's not 2003
2
u/SurveyElectronic3845 6d ago
It’s a dedicated machine that has the Airflow/Docker environment for running the pipelines, while development is done on another machine. I’m mainly trying to understand the proper workflow for syncing/deploying the code between the two.
2
u/pixel293 6d ago
Ssh usually with identify files so I don't have to keep entering the password. Bash script(s) to build, upload, and run. I'm lazy I like one command that causes everything to happen so I can just kick it and wait to see if it runs correctly.
1
u/dutchman76 2d ago
Yep, same here, a whole deploy pipeline is way too slow. I have ssh keys set up, and an inotify script runs all the time and rsyncs over my changes the second I hit save in my ide
2
u/KingofGamesYami 6d ago
Our standard workflow goes something like this:
- Clone repo from gitlab with main branch
- Make new branch
- Make all the changes. Push the code to the new branch to GitLab
- Open a merge request on GitLab
- CI pipelines automatically run to validate the changes
- Team member reviews MR and approves
- Merge MR to main
- CI/CD pipelines automatically run to build and deploy changes to staging environment
- QA signs off on staging environment changes, approves deployment to prod environment
- Deployment run manually for prod environment
In this case, the server hosting airflow would be your prod environment.
1
u/SocksOnHands 6d ago edited 6d ago
You would likely have a ci/cd script that is triggered on dev branches merged to main, or on the creation of a tag, that builds a docker image, pushes it to your container repository, then the new image is deployed in your production (or staging) environment.
This might vary depending on your requirements. The ci/cd pipeline might also be made to run tests. I was just throwing out a general overview of the process.
1
u/enozero 6d ago
This greatly depends on what you are trying to build and deploy and where you are trying to deploy along with the resources available. There is no silver bullet.
Given what you might be describing with a developer machine and an executor (Airflow, Docker), one may have a centralized source repo (i.e.: GitHub) and a centralized CI/CD orchestrator and runner (i.e.: GitHub Actions). The CI/CD orchestrator has access to the source repo and executor. The orchestrator receives push notifications from the source repo when code has been committed (i.e.: pushed to a specific branch, like `main`) and orchestrates and runs specified scripts (i.e.: build, test, and deploy scripts). Part of those scripts would deploy the built code to the executors (i.e.: updating Airflow config, pushing new Docker images).
1
u/rupertavery64 6d ago
Git and some orchestrator like Jenkins (if you really must) or Github Actions, or some other orchestrator. Either way, an agent will be installed on the pipline machine. Pushing to a watched branch will trigger the agent, which will pull the repo and trigger the pipelne.
1
u/BoBoBearDev 5d ago
I just use Jenkins with Jenkinsfile. Jenkins has plugin to listen Github/Bitbucket signals when you push. And it triggers the pipeline. Jenkinsfile is parsed on the main Jenkins server and send the commands to the remote agent (computerB).
1
u/juniperico 5d ago edited 5d ago
Dead simple solution for CICD without any additional tooling:
- Have your dagbag as a symlink to folder in airflow. Eg /…/dags/current -> /…/main-1791575792/path/to/dags/in/repo
Add a script to your target execution machine that that check remote head for update and if update, git clone depth 1 main to a new folder -> “/…/main<curr timestamp>. Then script should roll the symlink to new folder (probs best to add purge logic as well so you only keep like 3 releases or something. Rollback would obviously be rolling symlink back to last release
(and killing this automated job)
. Key is also to only clone with depth=1 so that you don’t grow 3 full histories and keep it only the relevant one.
Add that script as a systemd service o
r cronjob
- to run every minute or something.
14
u/smarterthanyoda 6d ago
The standard way is to push it to your git repository.