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

fix(cli): add git user configuration to local session #2877

Merged
merged 10 commits into from
May 12, 2022
17 changes: 16 additions & 1 deletion renku/core/session/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.
"""Docker based interactive session provider."""

import os.path
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Tuple, cast
from uuid import uuid4
Expand Down Expand Up @@ -158,6 +159,19 @@ def session_start(
docker.types.DeviceRequest(count=[gpu_request], capabilities=[["compute", "utility"]])
]

# NOTE: set git user
environment = {}
volumes = [f"{str(client.path.resolve())}:/home/jovyan/work"]
Panaetius marked this conversation as resolved.
Show resolved Hide resolved

global_git_config_path = os.path.normpath(os.path.expanduser("~/.gitconfig"))

if os.path.exists(global_git_config_path):
volumes.append(f"{global_git_config_path}:/home/jovyan/.gitconfig")
Panaetius marked this conversation as resolved.
Show resolved Hide resolved
else:
user = client.repository.get_global_user()
environment["GIT_AUTHOR_NAME"] = user.name
environment["GIT_AUTHOR_EMAIL"] = user.email

container = self.docker_client().containers.run(
image_name,
f'jupyter notebook --NotebookApp.ip="0.0.0.0" --NotebookApp.port={DockerSessionProvider.JUPYTER_PORT}'
Expand All @@ -167,7 +181,8 @@ def session_start(
labels={"renku_project": project_name, "jupyter_token": auth_token},
ports={f"{DockerSessionProvider.JUPYTER_PORT}/tcp": None},
remove=True,
volumes=[f"{str(client.path.resolve())}:/home/jovyan/work"],
environment=environment,
volumes=volumes,
**resource_requests,
)

Expand Down