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

fix running in bash environment on windows #6715

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

lainme
Copy link

@lainme lainme commented Jan 17, 2025

With this fix, aiida verdi commands can run on bash environment on windows, such as git bash

@unkcpz
Copy link
Member

unkcpz commented Jan 17, 2025

Thanks @lainme for the PR. I am not familiar with windows, @edan-bainglass could you give this a look. I guess the cmdline is not the only problem that we cannot support aiida natively on windows?

@lainme
Copy link
Author

lainme commented Jan 17, 2025

I have sucessfully run a simple example from aiida tutorial on windows. Here is what I do,

  • Install git bash
  • Install python3, patched aiida-core, graphviz, optionally install erlang and rabbitmq
  • Run verdi presto under git bash
  • Run python test.py as shown below
  • Run verdi process list -a to track the status
rom aiida import load_profile, engine, orm, plugins
from aiida.manage.configuration import get_config
from aiida.storage.sqlite_temp import SqliteTempBackend

load_profile('presto')

node = orm.Int(2)
node.store()

@engine.calcfunction
def multiply(x, y):
    return x * y

x = orm.load_node(pk=1)
y = orm.Int(3)
z = multiply(x,y)

print(x)
print(y)
print(z)

from aiida.tools.visualization import Graph
graph = Graph()
calc_node = orm.load_node(3)
graph.add_incoming(calc_node, annotate_links="both")
graph.add_outgoing(calc_node, annotate_links="both")
graph.graphviz.render('test.gv')

Here is some screenshot

image

To run aiida in jupyter on windows platform

  1. Install jupyter with pip install jupyter
  2. In .ipynb file, add the following on top of any other code, which will fix the asyncio error
import nest_asyncio
nest_asyncio.apply()

Here is the screenshot of running in jupyter notebook

image

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.00%. Comparing base (c88fc05) to head (bd0926c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6715      +/-   ##
==========================================
+ Coverage   78.00%   78.00%   +0.01%     
==========================================
  Files         563      563              
  Lines       41766    41771       +5     
==========================================
+ Hits        32574    32579       +5     
  Misses       9192     9192              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lainme lainme changed the title fix running in bash environment on windows fix verdi commands in bash environment on windows Jan 20, 2025
@lainme
Copy link
Author

lainme commented Jan 20, 2025

The previous modification only fixes the running of verdi commands and internal python code. New commits fix the running of simple external code (such as aiida-diff) under windows, and more verdi commands can run under powershell as well.

To make external code works, one should also make some modification to git bash (or other bash system on windows):

  • bash.exe should be added to PATH
  • ps --version should show it belongs to procps-ng, not cygwin.

In git bash, to use ps from procps-ng:

  • Download procps-ng package from https://repo.msys2.org/msys/x86_64/, unpackage the .zst format to .tar (you may use (https://www.tc4shell.com/en/7zip/modern7z/)
  • Open git bash as administrator, and run tar -xvf XXX.pkg.tar -C / usr
  • Make symlink ln -sf /usr/bin/procps /usr/bin/ps

@lainme lainme changed the title fix verdi commands in bash environment on windows fix running in bash environment on windows Jan 20, 2025
Copy link
Contributor

@agoscinski agoscinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you embed the suggested change in the pyproject.toml? Then we can run the CI

@@ -48,7 +48,8 @@ dependencies = [
'tqdm~=4.45',
'typing-extensions~=4.0;python_version<"3.10"',
'upf_to_json~=0.9.2',
'wrapt~=1.11'
'wrapt~=1.11',
'chardet'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just pinned most recent version

Suggested change
'chardet'
'chardet~=5.2.0 ; platform_system == "Windows"'

and then you need to run uv lock --upgrade-package chardet to put this into the uv.lock file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you do this we can run the CI

src/aiida/manage/configuration/config.py Show resolved Hide resolved
@agoscinski
Copy link
Contributor

agoscinski commented Jan 24, 2025

I the current state of this PR on the CI on windows and more than a third of the tests now pass, before this PR nothing would pass. See test suite run https://github.com/aiidateam/aiida-core/actions/runs/12950900268/job/36124705490?pr=6729 The test suite seems to crash (at least the errors are not properly reported after the run finishes), because of

Exception ignored in atexit callback: <bound method InteractiveShell.atexit_operations of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x0000019912B26CD0>>
Traceback (most recent call last):
  File "D:\a\aiida-core\aiida-core\.venv\Lib\site-packages\IPython\core\interactiveshell.py", line 3957, in atexit_operations
    tfile.unlink()
  File "C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\pathlib.py", line 1147, in unlink
    os.unlink(self)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpasaqzo87test_hist.sqlite'

Will need more time to actually mark the tests that are passing so we only run these ones in the CI. In any case I would not block this PR till we have something in the CI running windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants