Skip to content

Commit 9e017cd

Browse files
authored
Add support for symlinks in GH download (#3332)
* Add support for symlinks in GH download * Fix typo * Remove debug error
1 parent 8722dc8 commit 9e017cd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/zenml/integrations/github/code_repositories/github_code_repository.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,29 @@ def download_files(
187187
directory=local_path,
188188
repo_sub_directory=content.path,
189189
)
190+
# For symlinks, content.type is initially wrongly set to "file",
191+
# which is why we need to read it from the raw data instead.
192+
elif content.raw_data["type"] == "symlink":
193+
try:
194+
os.symlink(src=content.raw_data["target"], dst=local_path)
195+
except Exception as e:
196+
logger.error(
197+
"Failed to create symlink `%s` (%s): %s",
198+
content.path,
199+
content.html_url,
200+
e,
201+
)
190202
else:
191203
try:
192204
with open(local_path, "wb") as f:
193205
f.write(content.decoded_content)
194206
except (GithubException, IOError, AssertionError) as e:
195-
logger.error("Error processing %s: %s", content.path, e)
207+
logger.error(
208+
"Error processing `%s` (%s): %s",
209+
content.path,
210+
content.html_url,
211+
e,
212+
)
196213

197214
def get_local_context(self, path: str) -> Optional[LocalRepositoryContext]:
198215
"""Gets the local repository context.

0 commit comments

Comments
 (0)