Skip to content

Commit

Permalink
Big update (#24)
Browse files Browse the repository at this point in the history
* update everything

* yet another NPM update?

* whatever, use another syntax

* remove library from github repository

* test upload lib

* try again using a tag

* build it or download it, but do not fetch it

* update to latest commit

* add LnPP2

* add test make library

* add BASIS_ZIJLSTRA

* update content

* add BASIS_ccGRB_UZH
  • Loading branch information
pierre-24 authored Mar 21, 2024
1 parent a50c751 commit 54e9803
Show file tree
Hide file tree
Showing 22 changed files with 1,855 additions and 7,123 deletions.
1 change: 1 addition & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ commit = True
tag = True

[bumpversion:file:cp2k_basis/__init__.py]
[bumpversion:file:package.json]
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
python-version: '3.10'
- name: Install dependencies
run: |
pip3 install pip-tools
make install-dev
- name: Build
run: |
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/publish-library.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish library in (pre-)release

on:
push:
branches: [ master, dev ]

jobs:
build:
name: Make library
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
make install-dev
- name: Build
run: |
cb_fetch_data library/DATA_SOURCES.yml -o library.h5
- name: Upload pre-release version
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: library.h5
asset_name: latest_library.h5
tag: latest
overwrite: true
body: "Pre-release library"
- name: Upload release version
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: library.h5
asset_name: latest_library.h5
tag: ${{ github.ref }}
overwrite: true
body: "Stable release"
11 changes: 5 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Run tests

on:
push:
Expand All @@ -15,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9, '3.10']
python-version: [3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand All @@ -28,7 +25,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip3 install pip-tools
make install-dev
make install-front
- name: Lint
Expand All @@ -37,3 +33,6 @@ jobs:
- name: Test
run: |
TEST_FETCH_DATA=1 make test
- name: Test make library
run: |
cb_fetch_data library/DATA_SOURCES.yml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,6 @@ cython_debug/

node_modules/
cp2k_basis_webservice/static
tmp/
tmp/
library.h5
latest_library.h5
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ install:
pip install -e .

install-dev:
pip-sync
pip install -e .[dev]

install-front:
npm i
Expand Down
2 changes: 1 addition & 1 deletion cp2k_basis/base_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _read_metadata_hdf5(group: h5py.Group) -> dict:
metadata = {}

for key, values in group.attrs.items():
if type(values) == numpy.ndarray:
if type(values) is numpy.ndarray:
metadata[key] = list(values)
else:
metadata[key] = values
Expand Down
4 changes: 2 additions & 2 deletions cp2k_basis/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def integer(self) -> int:
try:
number = int(self.current_token.value)
except ValueError:
raise ParserSyntaxError('expected integer, got {}'.format(self.current_token.value))
raise ParserSyntaxError('expected integer, got {}'.format(self.current_token))

self.next()
return number
Expand All @@ -153,7 +153,7 @@ def number(self) -> float:
try:
number = float(self.current_token.value)
except ValueError:
raise ParserSyntaxError('expected number, got {}'.format(self.current_token.value))
raise ParserSyntaxError('expected number, got {}'.format(self.current_token))

self.next()
return number
Expand Down
2 changes: 1 addition & 1 deletion cp2k_basis_webservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Config:
API_LIMIT = '10/second'

# library
LIBRARY = 'library/library.h5'
LIBRARY = 'instance/library.h5'

# to be filled by `load_library()`
BASIS_SETS_STORAGE = None
Expand Down
34 changes: 15 additions & 19 deletions docs/developers/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

First, install node. **It is recommended to use [`nvm`](https://github.com/nvm-sh/nvm#install--update-script) to do so.**

Then:
Then, install the project and its dependencies:

```bash
# clone
Expand All @@ -21,33 +21,30 @@ make install-front

# build front
make front

# run the webservice:
# either:
make run
# or,
flask --app cp2k_basis_webservice run
```

If you want to use your own library of basis and pseudopotentials, check out [this page](library_build.md), and then:
Then, you can either build the library of basis sets and pseudopotentials, as described on [this page](library_build.md), or download its latest version (from the `dev` branch):

```bash
# create an instance folder
# see https://flask.palletsprojects.com/en/latest/config/#instance-folders
mkdir instance

# copy source
cp library/DATA_SOURCES.yml instance/

# after editing the DATA_SOURCES.yml file to fit your needs,
# run the `cb_fetch_data` command to create a new library:
cb_fetch_data instance/DATA_SOURCES.yml -o instance/library.h5
# To download the library, use:
wget https://github.com/pierre-24/cp2k-basis/releases/download/latest/latest_library.h5 -o instance/libary.h5

# setup a custom config
echo "LIBRARY='instance/library.h5'" > instance/settings.py
# Alternatively, to build the library from scratch, use the `cb_fetch_data` command:
cb_fetch_data library/DATA_SOURCES.yml -o instance/library.h5
```

And then you can restart the webservice.
And finally, you can start the webservice:

```bash
# either:
make run
# or,
flask --app cp2k_basis_webservice run
```

## Contribute

Expand Down Expand Up @@ -75,10 +72,9 @@ make install-front

### Tips to contribute

+ A useful setting is to setup the webservice to use the (smaller) test library for development:
+ A useful setting is to set up the webservice to use a (smaller) test library for development:

```bash
mkdir instance
echo "LIBRARY='tests/LIBRARY_EXAMPLE.h5'" > instance/settings.py
```

Expand Down
10 changes: 3 additions & 7 deletions docs/developers/library_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ From an existing YAML source file `DATA_SOURCE.yml` with the format described be
cb_fetch_data DATA_SOURCES.yml -o library.h5
```

This will create a [`library.h5` file](library_file_format.md), which might be exploited [latter on](#using-the-library).
This will create a [`library.h5` file](library_file_format.md), which might be exploited [later on](#using-the-library).

If you want to have insight on what is happening, you might want to use:

Expand Down Expand Up @@ -54,7 +54,7 @@ Keyword inside curly braces will be replaced by their value given in the `keywor

the base URL will be `https://github.com/cp2k/cp2k/raw/786bc82ff9ded3e1f761cba6d8e25c3c9fe19bb1/data/`.

Then, ach repository has different files (listed `files`).
Then, each repository has different files (listed `files`).

#### Files

Expand Down Expand Up @@ -166,7 +166,7 @@ The rules are the same as with `family_name`, but only the **first** result will
Finaly, `cb_fetch_data`, it will add metadata to those families.

To do so, the `metdata` dictionary will be used, in which the key is a REGEX matched against the name of the family.
The if there is a match, then all the values are attributed as metadata.
If there is a match, then all the values are attributed as metadata.

??? example
With:
Expand Down Expand Up @@ -247,9 +247,6 @@ This file will follow the same syntax as the one described above [for files](#fi
files:
- name: BASIS_MOLOPT_UCL
type: BASIS_SETS
family_name:
variant:
metadata:
```

You can now run `cb_explore_file` ... But nothing much happens:
Expand Down Expand Up @@ -281,7 +278,6 @@ Hopefully, the solution in this case is pretty straightforward: the name can be
'^(.*)(-q\d{1,2})$': '\1'
variant:
'^.*-(q\d{1,2})$': '\1'
metadata:
```

The result is better:
Expand Down
Loading

0 comments on commit 54e9803

Please sign in to comment.