Skip to content

Commit

Permalink
githubrunner: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamilcuk committed Jul 15, 2024
1 parent 1bfd9df commit 65b9383
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- nomad: 1.6.8
python: 3.7
name: Test
runs-on: nomadtools tag=ubuntu-latest
runs-on: nomadtools
steps:
- name: checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:

test_ssl:
name: Test ssl
runs-on: nomadtools tag=ubuntu-latest
runs-on: nomadtools
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -69,7 +69,7 @@ jobs:
- test_ssl
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
#if: github.ref == 'refs/heads/main'
runs-on: nomadtools tag=ubuntu-latest
runs-on: nomadtools
environment:
name: pypi
url: https://pypi.org/p/nomad-tools
Expand Down
24 changes: 15 additions & 9 deletions src/nomad_tools/entry_githubrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def get_runner_inactivity_timeout(self) -> Optional[datetime.timedelta]:
namespace: default
repos:
- Kamilcuk/runnertest
- Kamilcuk/nomad-tools
# - Kamilcuk
loop: 1
"""
Expand Down Expand Up @@ -582,7 +583,7 @@ def get_gh_repos() -> Set[GithubRepo]:
return set(flatten(parallelmap(get_gh_repos_one_to_many, set(CONFIG.repos))))


def get_gh_runs(repo: GithubRepo, run: dict) -> List[GithubJob]:
def get_gh_run_jobs(repo: GithubRepo, run: dict) -> List[GithubJob]:
interesting = "queued in_progress".split()
ret: List[GithubJob] = []
if run["status"] in interesting:
Expand All @@ -596,16 +597,21 @@ def get_gh_runs(repo: GithubRepo, run: dict) -> List[GithubJob]:
return ret


def get_gh_jobs(repo: GithubRepo) -> Iterable[GithubJob]:
runs = gh_get(
f"{CONFIG.github.url}/repos/{repo}/actions/runs",
"workflow_runs",
def get_gh_repo_jobs(repo: GithubRepo) -> Iterable[GithubJob]:
runs = flatten(
parallelmap(
lambda status: gh_get(
f"{CONFIG.github.url}/repos/{repo}/actions/runs?status={status}",
"workflow_runs",
),
["in_progress", "queued"],
)
)
return flatten(parallelmap(lambda x: get_gh_runs(repo, x), runs))
return flatten(parallelmap(lambda x: get_gh_run_jobs(repo, x), runs))


def get_gh_state(repos: Set[GithubRepo]) -> list[GithubJob]:
reqstate: list[GithubJob] = list(flatten(parallelmap(get_gh_jobs, repos)))
reqstate: list[GithubJob] = list(flatten(parallelmap(get_gh_repo_jobs, repos)))
# desc: str = ", ".join(s.labelsstr() + " for " + s.job_url() for s in reqstate)
# log.info(f"Found {len(reqstate)} required runners to run: {desc}")
for idx, s in enumerate(reqstate):
Expand Down Expand Up @@ -639,7 +645,7 @@ class NomadJob(nomadlib.Job, NomadJobCommon):

@dataclass
class GithubRunnerState:
inactive_since: Optional[datetime.datetime] = None
inactivu_since: Optional[datetime.datetime] = None


class NomadRunner(nomadlib.JobsJob, NomadJobCommon):

Check failure on line 651 in src/nomad_tools/entry_githubrunner.py

View workflow job for this annotation

GitHub Actions / Test (1.6.8, 3.7)

Base classes for class "NomadRunner" define method "setdefault" in incompatible way   Parameter 3 mismatch: base parameter has default argument value, override parameter does not (reportIncompatibleMethodOverride)

Check failure on line 651 in src/nomad_tools/entry_githubrunner.py

View workflow job for this annotation

GitHub Actions / Test (1.6.8, 3.7)

Base classes for class "NomadRunner" define method "update" in incompatible way   Parameter 2 type mismatch: base parameter is type "SupportsKeysAndGetItem[Unknown, Unknown]", override parameter is type "DataDict | dict[Unknown, Unknown]"   Parameter "**kwargs" has no corresponding parameter   Return type mismatch: base method returns type "None", override returns type "Self@DataDict"     Type "SupportsKeysAndGetItem[Unknown, Unknown]" is incompatible with type "DataDict | dict[Unknown, Unknown]"       "SupportsKeysAndGetItem[Unknown, Unknown]" is incompatible with "DataDict"       "SupportsKeysAndGetItem[Unknown, Unknown]" is incompatible with "dict[Unknown, Unknown]"     "DataDict*" is incompatible with "None" (reportIncompatibleMethodOverride)
Expand Down Expand Up @@ -1001,7 +1007,7 @@ def scheduler(self) -> Todo:
gj.labelsstr() for gj in self.githubjobs
)
runninglabelsstrs: dict[str, int] = collections.Counter(
nr.labelsstr() for nr in self.nomadrunners
nr.labelsstr() for nr in self.nomadrunners if not nr.is_dead()
)
alllabelsstrs: set[str] = set(
itertools.chain(neededlabelsstrs.keys(), runninglabelsstrs.keys())
Expand Down

0 comments on commit 65b9383

Please sign in to comment.