Skip to content

Commit

Permalink
fix(app): listing autosaves and debug statements (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Jul 19, 2022
1 parent 1b90451 commit 4e19998
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion renku_notebooks/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def authenticated(f):

@wraps(f)
def decorated(*args, **kwargs):
current_app.logger.debug(f"Getting headers, {list(request.headers.keys())}")
user = RegisteredUser(request.headers)
if current_app.config["ANONYMOUS_SESSIONS_ENABLED"] and not user.authenticated:
user = AnonymousUser(request.headers)
Expand Down
11 changes: 7 additions & 4 deletions renku_notebooks/api/classes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, headers):
if not self.authenticated:
return
self.git_url = current_app.config["GITLAB_URL"]
self.gitlab_client = Gitlab(self.git_url, api_version=4)
self.gitlab_client = Gitlab(self.git_url, api_version=4, per_page=50)
self.username = headers[self.auth_header]
self.safe_username = escapism.escape(self.username, escape_char="-").lower()
self.full_name = None
Expand Down Expand Up @@ -117,6 +117,7 @@ def __init__(self, headers):
self.git_url,
api_version=4,
oauth_token=self.git_token,
per_page=50,
)
self.setup_k8s()

Expand Down Expand Up @@ -156,12 +157,14 @@ def get_autosaves(self, namespace_project=None):
autosaves = []
# add any autosave branches, regardless of wheter pvcs are supported or not
if namespace_project is None: # get autosave branches from all projects
projects = self.gitlab_client.projects.list()
projects = self.gitlab_client.projects.list(iterator=True)
elif gl_project:
projects.append(gl_project)
for project in projects:
try:
branches = project.branches.list(search="^renku/autosave/")
branches = project.branches.list(
search="^renku/autosave/", iterator=True
)
except GitlabListError:
branches = []
for branch in branches:
Expand All @@ -172,7 +175,7 @@ def get_autosaves(self, namespace_project=None):
autosaves.append(autosave)
else:
current_app.logger.warning(
"Autosave branch {branch} for "
f"Autosave branch {branch} for "
f"{namespace_project} cannot be instantiated."
)
return autosaves
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,18 @@ def base_url():
@pytest.fixture(scope="session")
def registered_gitlab_client():
client = Gitlab(
os.environ["GITLAB_URL"], api_version=4, oauth_token=os.environ["GITLAB_TOKEN"]
os.environ["GITLAB_URL"],
api_version=4,
oauth_token=os.environ["GITLAB_TOKEN"],
per_page=50,
)
client.auth()
return client


@pytest.fixture(scope="session")
def anonymous_gitlab_client():
client = Gitlab(os.environ["GITLAB_URL"], api_version=4)
client = Gitlab(os.environ["GITLAB_URL"], api_version=4, per_page=50)
return client


Expand Down Expand Up @@ -465,7 +468,7 @@ def _create_remote_branch(branch_name, ref="HEAD"):

for branch in created_branches:
project = registered_gitlab_client.projects.get(branch.project_id)
pipelines = project.pipelines.list()
pipelines = project.pipelines.list(iterator=True)
for pipeline in pipelines:
if pipeline.sha == branch.commit["id"] and pipeline.ref == branch.name:
pipeline.cancel()
Expand Down

0 comments on commit 4e19998

Please sign in to comment.