ASAP icon indicating copy to clipboard operation
ASAP copied to clipboard

python package

Open gabor1 opened this issue 5 years ago • 13 comments

hi guys!

What is the plan and timescale of making this an installable python package? We are trying to use ASAP in a toolchain together with other tools, and finding it more difficult to work with it as is, paths need to be set specially etc. All this would go away if ASAP was installable as a python package.

gabor1 avatar Jan 30 '20 13:01 gabor1

We'll need to discuss a bit about this. Do you mean that you want to import ASAP as a library? IMO, given the current design, it makes more sense to add a script to install it (aka. adding the location of the package to PYTHONPATH).

BingqingCheng avatar Jan 31 '20 17:01 BingqingCheng

No not as a library. I understand that these are scripts. I would like these scripts to be installed in "standard" places, so that they can be found on the standard PATH that conda or other python installations use. (PYTHONPATH is for modules only).

-- Gábor

On 31 Jan 2020, at 17:01, Bingqing Cheng [email protected] wrote:

 We'll need to discuss a bit about this. Do you mean that you want to import ASAP as a library? IMO, given the current design, it makes more sense to add a script to install it (aka. adding the location of the package to PYTHONPATH).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabor1 avatar Jan 31 '20 19:01 gabor1

Okay. I see. I'll dig up on how to do this.

BingqingCheng avatar Feb 02 '20 18:02 BingqingCheng

a good test is whether the system() method from python can execute them...

-- Gábor

On 31 Jan 2020, at 19:28, Gabor Csanyi [email protected] wrote:

No not as a library. I understand that these are scripts. I would like these scripts to be installed in "standard" places, so that they can be found on the standard PATH that conda or other python installations use. (PYTHONPATH is for modules only).

-- Gábor

On 31 Jan 2020, at 17:01, Bingqing Cheng [email protected] wrote:

 We'll need to discuss a bit about this. Do you mean that you want to import ASAP as a library? IMO, given the current design, it makes more sense to add a script to install it (aka. adding the location of the package to PYTHONPATH).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabor1 avatar Feb 02 '20 19:02 gabor1

I've created a mock python package for ASAP on TestPyPI:

https://test.pypi.org/project/ASAP/

scripts are executable via the os.system() method. If this feature is satisfactory I can make a 'proper' python package that will install third-party dependencies like numpy!

Ryan-Rhys avatar Feb 03 '20 11:02 Ryan-Rhys

Fantastic. I tried it, seems to be working great!

BingqingCheng avatar Feb 03 '20 12:02 BingqingCheng

I can install the package, but I can’t then find the commands:

docker:~$ pip install -i https://test.pypi.org/simple/ ASAP Looking in indexes: https://test.pypi.org/simple/ Collecting ASAP Downloading https://test-files.pythonhosted.org/packages/ff/5b/9c214122c76f847d8643f9b85c578fbd3a6d8258c68e9c90038b467931f3/ASAP-0.0.1-py3-none-any.whl (55 kB) |████████████████████████████████| 55 kB 3.2 MB/s Installing collected packages: ASAP Successfully installed ASAP-0.0.1 docker:~$ gen_soap_descriptors.py bash: gen_soap_descriptors.py: command not found docker:~$ echo $PATH /opt/lammps/src/:/opt/quip/src/AtomEye/bin:/opt/quip/bin:/opt/julia/v1.1.0/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin docker:~$

-- Gábor

Gábor Csányi Professor of Molecular Modelling Engineering Laboratory, University of Cambridge Pembroke College Cambridge

Pembroke College supports CARA. A Lifeline to Academics at Risk. http://www.cara.ngo/

On 3 Feb 2020, at 12:09, Bingqing Cheng [email protected] wrote:

Fantastic. I tried it, seems to be working great!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabor1 avatar Feb 03 '20 15:02 gabor1

Are the commands findable with this package?

https://test.pypi.org/project/ASAP2/0.0.3/

Ryan-Rhys avatar Feb 03 '20 15:02 Ryan-Rhys

yes - they are now in /usr/local/bin. Do they always end up there, or do you have a way of figuring out where the current python environment likes to keep executables?

-- Gábor

Gábor Csányi Professor of Molecular Modelling Engineering Laboratory, University of Cambridge Pembroke College Cambridge

Pembroke College supports CARA. A Lifeline to Academics at Risk. http://www.cara.ngo/

On 3 Feb 2020, at 15:39, Ryan-Rhys Griffiths [email protected] wrote:

Are the commands findable with this package?

https://test.pypi.org/project/ASAP2/0.0.3/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabor1 avatar Feb 03 '20 15:02 gabor1

Yep, this is a problem because the scripts will be run by the system python. I'll look into how to ensure that they're run by the venv python!

Ryan-Rhys avatar Feb 03 '20 16:02 Ryan-Rhys

Apologies for the delay in responding; I have two conference submission deadlines over the coming two weeks and so these are demanding most of my attention!

With a command such as:

pip install -i https://test.pypi.org/simple/ ASAP2==0.0.3 --install-option="--install-scripts=path/to/custom_script_location"

it should be possible to specify a custom path to house the scripts. I can create a temporary python package on TestPyPi (@BingqingCheng presumably we're not ready to release on PyPi) now if this would substantially speed up your workflow?

Ryan-Rhys avatar Feb 06 '20 12:02 Ryan-Rhys

I have trouble in asap select

asap select  -n 100 -f dataset.xyz

then shows error

load xyz file:  dataset.xyz , a total of  3052 frames , a total of  439488 atoms , with elements:  [3, 5, 8] .
Find the following descriptor names that match the specifications:  ['']
Traceback (most recent call last):
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 448, in get_descriptors
  File "<__array_function__ internals>", line 5, in hstack
  File "/usr/lib/python3/dist-packages/numpy/core/shape_base.py", line 337, in hstack
    arrs = atleast_1d(*tup)
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 449, in <genexpr>
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 449, in <listcomp>
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hp/.local/bin/asap", line 11, in <module>
    load_entry_point('asaplib==0.0.1', 'console_scripts', 'asap')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/cli/cmd_asap.py", line 72, in select
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/cli/func_asap.py", line 80, in read_xyz_n_dm
  File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 452, in get_descriptors
IndexError: list index out of range

Wangmumu0403 avatar Mar 03 '22 01:03 Wangmumu0403

It looks to me that the dataset.xyz doesn’t contain descriptors, which are needed for the sparsification. Please try to use asap gen_desc to generate the descriptors first.

On Thu 3. Mar 2022 at 02:50, Wangmumu0403 @.***> wrote:

I have trouble in asap select

asap select -n 100 -f dataset.xyz

then shows error

load xyz file: dataset.xyz , a total of 3052 frames , a total of 439488 atoms , with elements: [3, 5, 8] . Find the following descriptor names that match the specifications: [''] Traceback (most recent call last): File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 448, in get_descriptors File "<array_function internals>", line 5, in hstack File "/usr/lib/python3/dist-packages/numpy/core/shape_base.py", line 337, in hstack arrs = atleast_1d(*tup) File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 449, in File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 449, in KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/hp/.local/bin/asap", line 11, in load_entry_point('asaplib==0.0.1', 'console_scripts', 'asap')() File "/usr/lib/python3/dist-packages/click/core.py", line 764, in call return self.main(*args, **kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/cli/cmd_asap.py", line 72, in select File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/cli/func_asap.py", line 80, in read_xyz_n_dm File "/home/hp/.local/lib/python3.8/site-packages/asaplib-0.0.1-py3.8.egg/asaplib/data/xyz.py", line 452, in get_descriptors IndexError: list index out of range

— Reply to this email directly, view it on GitHub https://github.com/BingqingCheng/ASAP/issues/11#issuecomment-1057579293, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABX4HLFJ7OIYHIRSUBWCOKTU6ALIFANCNFSM4KNVYOUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

BingqingCheng avatar Mar 03 '22 05:03 BingqingCheng