Skip to content
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/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.10", "3.14"]

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/update_changelog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash
# -*- coding: utf-8 -*-
"""Script for automatically updating the `CHANGELOG.md` based on the commits since the latest release tag."""

from pathlib import Path
import re
import subprocess
from pathlib import Path

DEFAULT_CHANGELOG_SECTIONS = """
### 鈥硷笍 Breaking changes
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/validate_release_tag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Validate that the version in the tag label matches the version of the package."""

import argparse
Expand Down
9 changes: 6 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Install pre-commit hooks via:
# pre-commit install
default_language_version:
python: python3.11

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-json

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.8.6
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
1 change: 0 additions & 1 deletion aiida_hyperqueue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
aiida_hyperqueue

Expand Down
5 changes: 2 additions & 3 deletions aiida_hyperqueue/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from .root import cmd_root # noqa: F401
from .alloc import cmd_add, cmd_list, cmd_remove # noqa: F401
from .install import cmd_install # noqa: F401
from .root import cmd_root # noqa: F401
from .server import cmd_info, cmd_start, cmd_stop # noqa: F401
from .alloc import cmd_list, cmd_add, cmd_remove # noqa: F401
3 changes: 1 addition & 2 deletions aiida_hyperqueue/cli/alloc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import click

from aiida.cmdline.params import options, arguments
from aiida.cmdline.params import arguments, options
from aiida.cmdline.utils import echo

from .root import cmd_root
Expand Down
12 changes: 6 additions & 6 deletions aiida_hyperqueue/cli/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import click
import tempfile
import requests
import tarfile
import tempfile
from pathlib import Path

import click
import requests

from aiida import orm
from aiida.cmdline.utils import echo

Expand Down Expand Up @@ -81,7 +81,7 @@ def cmd_install(
with computer.get_transport() as transport:
# Get the abs path of remote bin dir
retval, stdout, stderr = transport.exec_command_wait(
f"echo {str(remote_bin_dir)}"
f"echo {remote_bin_dir!s}"
)
if retval != 0:
echo.echo_critical(
Expand All @@ -102,7 +102,7 @@ def cmd_install(
)

# XXX: should transport.put take care of this already??
transport.exec_command_wait(f"chmod +x {str(remote_bin_dir / 'hq')}")
transport.exec_command_wait(f"chmod +x {remote_bin_dir / 'hq'!s}")

# write to bashrc
if write_bashrc:
Expand Down
1 change: 0 additions & 1 deletion aiida_hyperqueue/cli/params/arguments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from aiida.cmdline.params import arguments as core_arguments

COMPUTER = core_arguments.COMPUTER
2 changes: 1 addition & 1 deletion aiida_hyperqueue/cli/params/options.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""Reusable options for CLI commands."""

import functools

import click

from aiida.cmdline.params import options as core_options
from aiida.cmdline.params import types as core_types

Expand Down
1 change: 0 additions & 1 deletion aiida_hyperqueue/cli/root.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Command line interface `aiida-hq` for aiida-hyperqueue.
The CLI implementation prototype from `aiida-pseudo`.
"""
Expand Down
3 changes: 1 addition & 2 deletions aiida_hyperqueue/cli/server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import click

from aiida.cmdline.utils import echo

from .root import cmd_root
from .params import arguments
from .root import cmd_root


@cmd_root.group("server")
Expand Down
5 changes: 2 additions & 3 deletions aiida_hyperqueue/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved. #
# This file is part of the AiiDA code. #
Expand All @@ -14,8 +13,8 @@
import warnings

from aiida.common.extendeddicts import AttributeDict
from aiida.schedulers import Scheduler, SchedulerError, BashCliScheduler
from aiida.schedulers.datastructures import JobInfo, JobState, JobResource, JobTemplate
from aiida.schedulers import BashCliScheduler, Scheduler, SchedulerError
from aiida.schedulers.datastructures import JobInfo, JobResource, JobState, JobTemplate

# Mapping of HyperQueue states to AiiDA `JobState`s
_MAP_STATUS_HYPERQUEUE = {
Expand Down
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Sphinx configuration for aiida-hyperqueue
#
Expand All @@ -14,10 +13,10 @@
import time

import aiida_hyperqueue

from aiida import load_profile
from aiida.storage.sqlite_temp import SqliteTempBackend


# -- AiiDA-related setup --------------------------------------------------
temp_profile = SqliteTempBackend.create_profile("temp-profile")
load_profile(temp_profile, allow_switch=True)
Expand Down Expand Up @@ -69,7 +68,7 @@
copyright_year_string = (
current_year
if current_year == copyright_first_year
else "{}-{}".format(copyright_first_year, current_year)
else f"{copyright_first_year}-{current_year}"
)
# pylint: disable=redefined-builtin
copyright = "{}, {}. All rights reserved".format(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
"Natural Language :: English",
"Programming Language :: Python",
]
requires-python = ">=3.9"
requires-python = ">=3.10"

dependencies = [
"aiida-core~=2.7",
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Tests for the plugin.

Includes both tests written in unittest style (test_cli.py) and tests written
Expand Down
18 changes: 8 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
import contextlib
import json
import os
import signal
import subprocess
import time
from dataclasses import dataclass
from typing import Iterable, List, Optional, Tuple
from pathlib import Path
from collections.abc import Iterable

import pytest

Expand All @@ -32,7 +31,7 @@ def pytest_sessionstart(session):
hq_version = os.environ.get("HQ_VERSION", "v0.19.0")
install_command = f"wget -qO- https://github.com/It4innovations/hyperqueue/releases/download/{hq_version}/hq-{hq_version}-linux-x64.tar.gz | tar xvz -C {BIN_DIR.resolve()}"
print(install_command)
result = subprocess.run(install_command, shell=True)
result = subprocess.run(install_command, shell=True, check=False)
if result.returncode != 0:
raise Exception(f"Installation failed with return code {result.returncode}")

Expand Down Expand Up @@ -120,7 +119,7 @@ def kill_all(self):
if p.final_check:
raise e

def get_processes_by_name(self, name: str) -> Iterable[Tuple[int, ManagedProcess]]:
def get_processes_by_name(self, name: str) -> Iterable[tuple[int, ManagedProcess]]:
for i, p in enumerate(self.processes):
if p.name == name:
yield i, p
Expand All @@ -132,8 +131,7 @@ def kill_process(self, name: str, signal: int = signal.SIGTERM) -> subprocess.Po
if p.process.returncode is None and not p.process.poll():
os.killpg(os.getpgid(p.process.pid), signal)
return p.process
else:
raise Exception("Process not found")
raise Exception("Process not found")

def sort_processes_for_kill(self):
pass
Expand Down Expand Up @@ -192,7 +190,7 @@ def start_server(
self.check_running_processes()
return process

def start_workers(self, count, **kwargs) -> List[subprocess.Popen]:
def start_workers(self, count, **kwargs) -> list[subprocess.Popen]:
workers = []
for _ in range(count):
workers.append(self.start_worker(**kwargs))
Expand All @@ -208,7 +206,7 @@ def start_worker(
wait_for_start=True,
on_server_lost="stop",
server_dir=None,
work_dir: Optional[str] = None,
work_dir: str | None = None,
final_check: bool = False,
hostname=None,
) -> subprocess.Popen:
Expand Down Expand Up @@ -274,7 +272,7 @@ def kill_worker(self, worker_id: int, signal: int = signal.SIGTERM, wait=True):
if wait:
wait_until(lambda: process.poll() is not None)

def find_process_by_pid(self, pid: int) -> Optional[ManagedProcess]:
def find_process_by_pid(self, pid: int) -> ManagedProcess | None:
for p in self.processes:
if p.process.pid == pid:
return p
Expand All @@ -294,7 +292,7 @@ def command(
ignore_stderr=False,
env=None,
use_server_dir=True,
cmd_prefix: Optional[List[str]] = None,
cmd_prefix: list[str] | None = None,
):
cmd_prefix = cmd_prefix if cmd_prefix is not None else []
if isinstance(args, str):
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli_alloc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
from click.testing import CliRunner

Expand Down
6 changes: 2 additions & 4 deletions tests/test_cli_install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
import pytest
from click.testing import CliRunner

from aiida_hyperqueue.cli import cmd_install
from click.testing import CliRunner


@pytest.fixture
Expand All @@ -18,7 +16,7 @@ def test_install(runner, tmp_path, aiida_computer_local):
cmd_install,
[
"-p",
f"{str(tmp_path.resolve())}",
f"{tmp_path.resolve()!s}",
"--hq-version",
version,
"--no-write-bashrc",
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cli_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import pytest
import time

import pytest
from aiida_hyperqueue.cli import cmd_info, cmd_start, cmd_stop
from click.testing import CliRunner

from aiida.transports.transport import Transport as TransportClass
from aiida_hyperqueue.cli import cmd_info, cmd_start, cmd_stop

from .conftest import HqEnv, get_hq_binary

Expand Down Expand Up @@ -57,11 +57,11 @@ def _mock_exec_command_wait(obj, command: str, **kwargs):
cmd_list = command.split(" ")
if command.startswith("hq"): # `hq`
command = " ".join(
[f"{hq}", "--server-dir", f"{str(tmp_path.resolve())}"] + cmd_list[1:]
[f"{hq}", "--server-dir", f"{tmp_path.resolve()!s}"] + cmd_list[1:]
)
elif command.startswith("nohup hq"): # `nohup hq`
command = " ".join(
[f"nohup {hq}", "--server-dir", f"{str(tmp_path.resolve())}"]
[f"nohup {hq}", "--server-dir", f"{tmp_path.resolve()!s}"]
+ cmd_list[2:]
)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
"""Tests for command line interface."""

import pytest
import uuid
from pathlib import Path

from aiida.schedulers import JobState
import pytest
from aiida_hyperqueue.scheduler import HyperQueueJobResource, HyperQueueScheduler

from aiida.common.datastructures import CodeRunMode
from aiida.schedulers import JobState
from aiida.schedulers.datastructures import JobTemplate, JobTemplateCodeInfo
from aiida_hyperqueue.scheduler import HyperQueueJobResource, HyperQueueScheduler

from .conftest import HqEnv
from .utils import wait_for_job_state
Expand Down
7 changes: 3 additions & 4 deletions tests/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from .table import JOB_TABLE_ROWS, parse_table, parse_tables
from .wait import wait_for_job_state, wait_for_worker_state

__all__ = [
"wait_for_job_state",
"wait_for_worker_state",
"JOB_TABLE_ROWS",
"parse_table",
"parse_tables",
"JOB_TABLE_ROWS",
"wait_for_job_state",
"wait_for_worker_state",
]
8 changes: 2 additions & 6 deletions tests/utils/cmd.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# -*- coding: utf-8 -*-
from typing import List


def python(command: str) -> List[str]:
def python(command: str) -> list[str]:
"""
Returns commands that will run the specified command as a Python script.
"""
return ["python3", "-c", command]


def bash(command: str) -> List[str]:
def bash(command: str) -> list[str]:
"""
Returns commands that will run in a bash script.
"""
Expand Down
1 change: 0 additions & 1 deletion tests/utils/io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import socket
from contextlib import closing

Expand Down
Loading
Loading