<@ULVA73B9P> when I do a pull of my repo from gith...
# ask-marvin
a
@Marvin when I do a pull of my repo from github I find that that name generated is a concatenation of repo_namebranch_name. The issue is that in my code I have imports by repo_name and that concatenation of folder naming is causing path error in my runs on workers. Can you tell me if I can rename that ?
Copy code
- prefect.deployments.steps.git_clone:
        repository: <https://github.com/PrefectHQ/prefect.git>
        branch: my-branch
m
thought for 257.8 seconds
Short answer: In Prefect 3.x, the
prefect.deployments.steps.git_clone
step does not expose a parameter to control the checkout folder name. It will create
<repo>
or
<repo>-<branch>
(slashes in branches are replaced with
-
). So you can’t rename it via a step argument. Your options: - Most common fix: set the working directory to the cloned repo so imports resolve correctly
Copy code
pull:
    - prefect.deployments.steps.git_clone:
        id: repo
        repository: <https://github.com/PrefectHQ/prefect.git>
        branch: my-branch
    - prefect.deployments.steps.set_working_directory:
        directory: "{{ repo.directory }}"
This avoids relying on the outer folder name. If your package lives at the repo root (e.g.,
repo_name/
),
import repo_name
will work once the working dir is set. - Rename the folder after clone (if you truly need a specific name)
Copy code
pull:
    - prefect.deployments.steps.git_clone:
        id: repo
        repository: <https://github.com/PrefectHQ/prefect.git>
        branch: my-branch
    - prefect.deployments.steps.run_shell_script:
        script: |
          mv "{{ repo.directory }}" "prefect"
    - prefect.deployments.steps.set_working_directory:
        directory: ./prefect
- Bypass
git_clone
and clone to a chosen directory yourself
Copy code
pull:
    - prefect.deployments.steps.run_shell_script:
        script: |
          git clone --branch my-branch <https://github.com/PrefectHQ/prefect.git> prefect
    - prefect.deployments.steps.set_working_directory:
        directory: ./prefect
If you need auth for a private repo, you can inject a token via env variables or a Secret block. - If you deploy via Python, you can control the folder name using
GitRepository(name=...)
Copy code
from prefect import flow
  from prefect.runner.storage import GitRepository

  flow.from_source(
      GitRepository(
          url="<https://github.com/PrefectHQ/prefect.git>",
          branch="my-branch",
          name="prefect",  # desired checkout directory
      ),
      entrypoint="path/to/flow.py:my_flow",
  ).deploy(
      name="my-deployment",
      work_pool_name="my-pool",
  )
Docs: - git_clone and set_working_directory - run_shell_script Quick question to ensure the best path: are your imports failing because the Python package directory differs from the repo root name, or because you’re constructing paths that include the literal repo folder name? If it’s the latter, pointing
set_working_directory
at
{{ repo.directory }}
is usually the simplest fix.
a
Copy code
pull:
    - prefect.deployments.steps.run_shell_script:
        script: |
          git clone --branch my-branch <https://github.com/PrefectHQ/prefect.git> prefect
    - prefect.deployments.steps.set_working_directory:
        directory: ./prefect
and how to include the access token in the git command there ?
n
hi @Akram Gharbi you have to tag marvin at this time