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

moves tests inside poetry run in workflow #406

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests
poetry run pytest tests
24 changes: 13 additions & 11 deletions browse/commands/invalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@bp.cli.command(short_help="invalidates CDN for PDFs from a mailing")
@click.argument("mailings",
#help="Invalidate all PDFs from these mailings. May have more than one. Format YYMMDD.",
# help="Invalidate all PDFs from these mailings. May have more than one. Format YYMMDD.",
nargs=-1)
@click.option("--project", default="arxiv-production")
@click.option("--cdn", default="browse-arxiv-org-load-balancer2",
Expand All @@ -28,7 +28,7 @@
@click.option("-v", is_flag=True,
help="Verbose.",
default=False)
def invalidate_mailings(project: str, cdn: str, mailings: List[str], dry_run: bool, v: bool):
def invalidate_mailings(project: str, cdn: str, mailings: List[str], dry_run: bool, v: bool) -> None:
"""Invalidate CDN for PDFs in a mailing."""
if not mailings:
raise ValueError("mailing must not be empty.")
Expand All @@ -45,11 +45,11 @@ def invalidate_mailings(project: str, cdn: str, mailings: List[str], dry_run: bo
papers = (session.query(NextMail.paper_id, NextMail.version)
.filter(NextMail.mail_id == int(mailing)))

nn=0;
nn = 0;
for paper_id, version in papers.all():
paths.append(f"/pdf/{paper_id}.pdf")
paths.append(f"/pdf/{paper_id}v{version}.pdf")
nn = nn+1
nn = nn + 1

if v:
print(f"For {mailing} found {nn} papers.")
Expand All @@ -61,7 +61,7 @@ def invalidate_mailings(project: str, cdn: str, mailings: List[str], dry_run: bo
_invalidate(project, cdn, paths, dry_run=dry_run, v=v)


def _invalidate(proj: str, cdn: str, paths: Iterable[str], dry_run: bool = False, v: bool = False):
def _invalidate(proj: str, cdn: str, paths: List[str], dry_run: bool = False, v: bool = False) -> None:
"""Invalidates `paths` on `cdn` in `proj`."""
paths.sort()
if v:
Expand All @@ -80,18 +80,20 @@ def _invalidate(proj: str, cdn: str, paths: Iterable[str], dry_run: bool = False
url_map=cdn,
cache_invalidation_rule_resource=
compute_v1.CacheInvalidationRule(
#host="*",
# host="*",
path=path),
)
_invalidate_req(client, request)
if v:
print(f"Invalidated {path}.")

def _exception_pred(ex:Exception) -> bool:
return (ex and
(isinstance(ex, BaseException)
or "rate limit exceeded" in str(ex).lower()))

def _exception_pred(ex: Exception) -> bool:
return bool(ex and
(isinstance(ex, BaseException)
or "rate limit exceeded" in str(ex).lower()))


@retry.Retry(predicate=_exception_pred)
def _invalidate_req(client, request) -> None:
def _invalidate_req(client: compute_v1.UrlMapsClient, request: compute_v1.InvalidateCacheUrlMapRequest) -> None:
client.invalidate_cache_unary(request=request)
Loading