Source custom shell script when running in remote virtual environment

I am using a ssh remote with the following setup:

remotes:
  azure-deeplearning:
    type: ssh
    host: deeplearning.guild.ai
    venv-path: mypath/.training_venv
    user: myuser
    use-prerelease: yes

The venv gets correctly activated. The issue is that I need to source a setup file after the venv gets activated. If I were to do it manually on the remote I would do:

source mypath/.training-venv/bin/activate
source my_custom_bash.sh

How would this fit into the guild remote workflow?

My apologies for the late reply! I had typed a reply but never send it.

You can use something like this:

remotes:
  azure-deeplearning:
    venv-activate: source mypath/.training_venv/bin/activate && source my_custom_bash.sh

Refer to Remotes Reference for info on the venv-activate attribute for ssh remotes.

Thank you for this. This works, but I also want to change the working directory to mypath. I have tried using cd in the venv-activate but that breaks. I also tried using the remoteCommand in my ssh config, but that wont’ work either.

The current working directory should not be meaningful in the context of a remote environment. Guild will use the remote run directory as cwd.