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

Upload GitHub directory takes more time than necessary #519

Closed
anders-kiaer opened this issue Sep 22, 2021 · 0 comments · Fixed by #521
Closed

Upload GitHub directory takes more time than necessary #519

anders-kiaer opened this issue Sep 22, 2021 · 0 comments · Fixed by #521
Assignees
Labels
enhancement 🚀 New feature or request good first issue Good for newcomers

Comments

@anders-kiaer
Copy link
Collaborator

The current function,

def upload_directory(
github_slug: str,
source_directory: Path,
commit_message: str = "Initial commit",
branch_name: str = "main",
) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
temp_dir = Path(tmp_dir)
subprocess.run(
["git", "clone", f"git@github.com:{github_slug}"],
check=True,
cwd=temp_dir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
clone_path = temp_dir / github_slug.split("/")[1]
copy_tree(str(source_directory), str(clone_path))
# dirs_exist_ok first available in Python 3.8.
# shutil.copytree(source_directory, clone_path, dirs_exist_ok=True)
commands = [
["git", "add", "."],
["git", "commit", "-m", commit_message],
["git", "branch", "-M", branch_name],
["git", "push", "-u", "origin", branch_name],
]
for command in commands:
subprocess.run(
command,
check=True,
cwd=clone_path,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
, use more time than necessary. It copies over resources folder (which could be huge) to the cloned path, even though this subfolder is part of .gitignore and not uploaded (instead it is uploaded to blob storage in a later step).

Ignore resources folder to potentially safe quite some runtime. shutil.copytree supports e.g. ignore_patterns (https://docs.python.org/3/library/shutil.html#shutil.ignore_patterns).

@anders-kiaer anders-kiaer added enhancement 🚀 New feature or request good first issue Good for newcomers labels Sep 22, 2021
@anders-kiaer anders-kiaer self-assigned this Sep 22, 2021
@anders-kiaer anders-kiaer moved this to Done 🏁 in Webviz Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant