Skip to content

Commit

Permalink
Merge branch 'main' into fix-windows-running
Browse files Browse the repository at this point in the history
  • Loading branch information
agoscinski authored Feb 10, 2025
2 parents 440b983 + f56fcc3 commit 5784490
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docker~=7.0.0
pytest~=8.2.0
requests~=2.32.0
pytest-docker~=3.1.0
pytest-docker~=3.2.0
4 changes: 2 additions & 2 deletions .docker/tests/test_aiida.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def test_correct_python_version_installed(aiida_exec, python_version):
info = json.loads(aiida_exec('mamba list --json --full-name python').decode())[0]
info = json.loads(aiida_exec('mamba list --json --full-name python', ignore_stderr=True).decode())[0]
assert info['name'] == 'python'
assert parse(info['version']) == parse(python_version)

Expand All @@ -15,7 +15,7 @@ def test_correct_pgsql_version_installed(aiida_exec, pgsql_version, variant):
if variant == 'aiida-core-base':
pytest.skip('PostgreSQL is not installed in the base image')

info = json.loads(aiida_exec('mamba list --json --full-name postgresql').decode())[0]
info = json.loads(aiida_exec('mamba list --json --full-name postgresql', ignore_stderr=True).decode())[0]
assert info['name'] == 'postgresql'
assert parse(info['version']).major == parse(pgsql_version).major

Expand Down
4 changes: 2 additions & 2 deletions .github/actions/install-aiida-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ runs:
python-version: ${{ inputs.python-version }}

- name: Set up uv
uses: astral-sh/[email protected].0
uses: astral-sh/[email protected].1
with:
version: 0.5.x
version: 0.5.22
python-version: ${{ inputs.python-version }}

- name: Install dependencies from uv lock
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: aiida-pytests-py3.9
file: ./coverage.xml
files: ./coverage.xml
fail_ci_if_error: false # don't fail job, if coverage upload fails

tests-presto:
Expand Down Expand Up @@ -126,8 +126,6 @@ jobs:
with:
python-version: '3.12'
from-lock: 'true'
# NOTE: The `verdi devel check-undesired-imports` fails if
# the 'tui' extra is installed.
extras: ''

- name: Run verdi tests
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,11 @@ jobs:
images: ${{ needs.build.outputs.images }}
registry: ghcr.io

# IMPORTANT: To save arm64 runners resources,
# we run the test only when pushing to main.
# We also only test the aiida-core-dev image.
test-arm64:
needs: build
if: >-
github.repository == 'aiidateam/aiida-core'
&& (github.ref_type == 'tag' || github.ref_name == 'main')
uses: ./.github/workflows/docker-test.yml
with:
runsOn: buildjet-4vcpu-ubuntu-2204-arm
runsOn: ubuntu-22.04-arm
images: ${{ needs.build.outputs.images }}
target: aiida-core-dev

Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ jobs:
python-version: '3.11'

- name: Set up uv
uses: astral-sh/[email protected].0
uses: astral-sh/[email protected].1
with:
version: 0.5.x
version: latest

- name: Install utils/ dependencies
run: uv pip install --system -r utils/requirements.txt

- name: Validate uv lockfile
run: uv lock --check

- name: Validate conda environment file
run: python ./utils/dependency_management.py validate-environment-yml

Expand Down
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autofix_prs: true
autoupdate_commit_msg: 'Devops: Update pre-commit dependencies'
autoupdate_schedule: quarterly
skip: [mypy, check-uv-lock, generate-conda-environment, validate-conda-environment, verdi-autodocs]
skip: [mypy, generate-conda-environment, validate-conda-environment, verdi-autodocs]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -56,6 +56,12 @@ repos:
environment.yml|
)$
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.22
hooks:
# Check and update the uv lockfile
- id: uv-lock

- repo: local

hooks:
Expand Down Expand Up @@ -187,18 +193,6 @@ repos:
src/aiida/workflows/arithmetic/multiply_add.py|
)$
- id: check-uv-lock
name: Check uv lockfile up to date
# NOTE: This will not automatically update the lockfile
entry: uv lock --check
language: system
pass_filenames: false
files: >-
(?x)^(
pyproject.toml|
uv.lock|
)$
- id: generate-conda-environment
name: Update conda environment file
entry: python ./utils/dependency_management.py generate-environment-yml
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ build:
# https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-uv
pre_create_environment:
- asdf plugin add uv
- asdf install uv 0.5.20
- asdf global uv 0.5.20
- asdf install uv 0.5.22
- asdf global uv 0.5.22
create_environment:
- uv venv
install:
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,8 @@ commands = molecule {posargs:test}
"""

[tool.uv]
required-version = ">=0.5.20"
# NOTE: When you bump the minimum uv version, you also need to change it in:
# .pre-commit-config.yaml
# .github/actions/install-aiida-core/action.yml
# .readthedocs.yml
required-version = ">=0.5.21"
12 changes: 8 additions & 4 deletions src/aiida/cmdline/commands/cmd_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ def devel_check_load_time():
def devel_check_undesired_imports():
"""Check that verdi does not import python modules it shouldn't.
Note: The blacklist was taken from the list of packages in the 'atomic_tools' extra but can be extended.
This is to keep the verdi CLI snappy, especially for tab-completion.
"""
loaded_modules = 0

for modulename in [
'asyncio',
unwanted_modules = [
'requests',
'plumpy',
'disk_objectstore',
Expand All @@ -78,7 +77,12 @@ def devel_check_undesired_imports():
'spglib',
'pymysql',
'yaml',
]:
]
# trogon powers the optional TUI and uses asyncio.
# Check for asyncio only when the optional tui extras are not installed.
if 'trogon' not in sys.modules:
unwanted_modules += 'asyncio'
for modulename in unwanted_modules:
if modulename in sys.modules:
echo.echo_warning(f'Detected loaded module "{modulename}"')
loaded_modules += 1
Expand Down
6 changes: 3 additions & 3 deletions src/aiida/transports/plugins/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def rename(self, oldpath: TransportPath, newpath: TransportPath):
:param str oldpath: existing name of the file or folder
:param str newpath: new name for the file or folder
:raises OSError: if src/dst is not found
:raises OSError: if oldpath is not found or newpath already exists
:raises ValueError: if src/dst is not a valid string
"""
oldpath = str(oldpath)
Expand All @@ -883,8 +883,8 @@ def rename(self, oldpath: TransportPath, newpath: TransportPath):
raise ValueError(f'Destination {newpath} is not a valid string')
if not os.path.exists(oldpath):
raise OSError(f'Source {oldpath} does not exist')
if not os.path.exists(newpath):
raise OSError(f'Destination {newpath} does not exist')
if os.path.exists(newpath):
raise OSError(f'Destination {newpath} already exists.')

shutil.move(oldpath, newpath)

Expand Down
14 changes: 5 additions & 9 deletions src/aiida/transports/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,8 @@ def rename(self, oldpath: TransportPath, newpath: TransportPath):
:param str oldpath: existing name of the file or folder
:param str newpath: new name for the file or folder
:raises OSError: if oldpath/newpath is not found
:raises ValueError: if sroldpathc/newpath is not a valid path
:raises OSError: if oldpath is not found or newpath already exists
:raises ValueError: if oldpath/newpath is not a valid path
"""
if not oldpath:
raise ValueError(f'Source {oldpath} is not a valid path')
Expand All @@ -1371,13 +1371,9 @@ def rename(self, oldpath: TransportPath, newpath: TransportPath):
if not self.isfile(oldpath):
if not self.isdir(oldpath):
raise OSError(f'Source {oldpath} does not exist')
# TODO: this seems to be a bug (?)
# why to raise an OSError if the newpath does not exist?
# ofcourse newpath shouldn't exist, that's why we are renaming it!
# issue opened here: https://github.com/aiidateam/aiida-core/issues/6725
if not self.isfile(newpath):
if not self.isdir(newpath):
raise OSError(f'Destination {newpath} does not exist')

if self.path_exists(newpath):
raise OSError(f'Destination {newpath} already exist')

return self.sftp.rename(oldpath, newpath)

Expand Down
25 changes: 25 additions & 0 deletions tests/transports/test_all_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,3 +1232,28 @@ def test_asynchronous_execution(custom_transport, tmp_path):
except ProcessLookupError:
# If the process is already dead (or has never run), I just ignore the error
pass


def test_rename(custom_transport, tmp_path_remote):
"""Test the rename function of the transport plugin."""
with custom_transport as transport:
old_file = tmp_path_remote / 'oldfile.txt'
new_file = tmp_path_remote / 'newfile.txt'
another_file = tmp_path_remote / 'anotherfile.txt'

# Create a test file to rename
old_file.touch()
another_file.touch()
assert old_file.exists()
assert another_file.exists()

# Perform rename operation
transport.rename(old_file, new_file)

# Verify rename was successful
assert not old_file.exists()
assert new_file.exists()

# Perform rename operation if new file already exists
with pytest.raises(OSError, match='already exist|destination exists'):
transport.rename(new_file, another_file)

0 comments on commit 5784490

Please sign in to comment.