Skip to content

Commit

Permalink
Merge pull request #17 from openkim/setup-upgrade
Browse files Browse the repository at this point in the history
Setup upgrade
  • Loading branch information
yafshar committed Mar 25, 2024
2 parents f63ee64 + 44064f4 commit 4cd5b20
Show file tree
Hide file tree
Showing 32 changed files with 564 additions and 15,484 deletions.
23 changes: 0 additions & 23 deletions .appveyor.yml

This file was deleted.

17 changes: 10 additions & 7 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -18,23 +19,25 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install kim-edn
pip install kim-edn>1.4.0
pip install coverage
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=40 --max-line-length=127 --statistics --exclude external
- name: Test with unittest
run: |
python -m tests
coverage run -m tests
- name: Post Coverage
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

fail_ci_if_error: true
flags: unittests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 4 additions & 3 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install --upgrade build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.8.11
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD_OPENKIM }}

2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
include LICENSE
include versioneer.py
include kim_property/_version.py
recursive-include kim_property/properties *
50 changes: 39 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# KIM-PROPERTY utility module

[![Python package](https://github.com/openkim/kim-property/workflows/Python%20package/badge.svg)](https://github.com/openkim/kim-property/actions)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/5860x3twnmpwwmsa?svg=true)](https://ci.appveyor.com/project/yafshar/kim-property)
[![codecov](https://codecov.io/gh/openkim/kim-property/branch/master/graph/badge.svg)](https://codecov.io/gh/openkim/kim-property)
[![Anaconda-Server Badge](https://img.shields.io/conda/vn/conda-forge/kim-property.svg)](https://anaconda.org/conda-forge/kim-property)
[![PyPI](https://img.shields.io/pypi/v/kim-property.svg)](https://pypi.python.org/pypi/kim-property)
Expand All @@ -13,29 +12,32 @@ example a [LAMMPS](https://lammps.sandia.gov/) script) that computes a

This utility module has 5 modes:

1- **[Create](#Create)**\
1- **[Create](#create)**\
Take as input the property instance ID and property definition name and
create initial property instance data structure. It checks and indicates
whether the property definition exists in [OpenKIM](https://openkim.org/).

2- **[Destroy](#Destroy)**\
2- **[Destroy](#destroy)**\
Delete a previously created property instance ID.

3- **[Modify](#Modify)**\
3- **[Modify](#modify)**\
Incrementally build the property instance by receiving keys with
associated arguments. It can "append" and add to a key's existing array
argument.

4- **[Remove](#Remove)**\
4- **[Remove](#remove)**\
Remove a key.

5- **[Dump](#Dump)**\
5- **[Dump](#dump)**\
Take as input the generated instance and a filename, validate each
instance against the property definition and either issues an error or
writes the instance out to file in edn format. Final validation should
make sure all keys/arguments are legal and all required keys are
provided.

To get started, you'll need to install the `kim-property` package. Please refer
to the [installation instructions](#installing-kim-property).

## Create

Creating property instances::
Expand Down Expand Up @@ -796,30 +798,56 @@ For more information and examples, see the

**conda** is the package management tool for Anaconda Python installations.

Installing `kim-property` from the `conda-forge` channel can be achieved by
adding `conda-forge` to your channels with:
Installing `kim-property` from the `conda-forge` channel can be achieved
by adding `conda-forge` to your channels with:

```sh
conda config --add channels conda-forge
conda config --set channel_priority strict
```

Once the `conda-forge` channel has been enabled, `kim-property` can be
installed with:
installed with `conda`:

```sh
conda install kim-property
```

or with `mamba`:

```sh
mamba install kim-property
```

It is possible to list all of the versions of `kim-property` available on
your platform with:
your platform with `conda`:

```sh
conda search kim-property --channel conda-forge
```

or with `mamba`:

```sh
mamba search kim-property --channel conda-forge
```

Alternatively, `mamba repoquery` may provide more information:

```sh
# Search all versions available on your platform:
mamba repoquery search kim-property --channel conda-forge

# List packages depending on `kim-property`:
mamba repoquery whoneeds kim-property --channel conda-forge

# List dependencies of `kim-property`:
mamba repoquery depends kim-property --channel conda-forge
```

## Copyright

Copyright (c) 2020-2023, Regents of the University of Minnesota.\
Copyright (c) 2020-2024, Regents of the University of Minnesota.\
All Rights Reserved

## Contributing
Expand Down
22 changes: 10 additions & 12 deletions external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,40 @@ git submodule update --remote

Once you cloned the repository with external submodule and fetch all the latest
changes from
[`openkim-properties`](https://github.com/openkim/openkim-properties.git). First, if properties have been added or removed, update the lists ``kim_property_names`` and ``kim_property_ids`` in ``kim_property/pickle.py``. Then, in the package main directory,
[`openkim-properties`](https://github.com/openkim/openkim-properties.git).
First, if properties have been added or removed, update the lists
``kim_property_names`` and ``kim_property_ids`` in ``kim_property/ednify.py``.
Then, in the package main directory,

```sh
├── LICENSE
├── MANIFEST.in
├── README.md
├── external
├── kim_property
├── setup.cfg
├── pyproject.toml
├── setup.py
├── tests
└── versioneer.py
└── tests
```

please run python and do as,

```sh
python
>>> import kim_property
>>> kim_property.pickle.pickle_kim_properties()
>>> kim_property.ednify.ednify_kim_properties()
```

Now, you have the latest update from
[`openkim-properties`](https://github.com/openkim/openkim-properties.git).

**NOTE:**

Suppose you are a developer with write access to the `kim-property` repository
If you are a developer with a write access to the `kim-property` repository
and would like to update the property definition with the new updates. In that
case, you should commit and publish your changes to the repository and make a
new release. This release will update the binary distribution of the package
with the latest changes.

Please install the `kim-property` package using pip in the package main
directory,

```sh
pip install .
```
To get started, you'll need to install the `kim-property` package. Please refer
to the [installation instructions](../README.md#installing-kim-property).
6 changes: 2 additions & 4 deletions kim_property/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@
}
]
"""

from . import _version
""" # noqa: E501

from .err import KIMPropertyError
from .definition import \
Expand Down Expand Up @@ -433,5 +431,5 @@

__author__ = 'Yaser Afshar <yafshar@umn.edu>'

from . import _version # noqa: E402
__version__ = _version.get_versions()['version']

2 changes: 1 addition & 1 deletion kim_property/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_config() -> VersioneerConfig:
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440"
cfg.tag_prefix = ""
cfg.tag_prefix = "v"
cfg.parentdir_prefix = "kim_property-"
cfg.versionfile_source = "kim_property/_version.py"
cfg.verbose = False
Expand Down
31 changes: 13 additions & 18 deletions kim_property/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .err import KIMPropertyError
from .definition import check_property_definition
from .instance import get_property_id_path, check_instance_id_format
from .pickle import unpickle_kim_properties
from .ednify import unednify_kim_properties

__all__ = [
"get_properties",
Expand All @@ -26,14 +26,14 @@

# Get the standard KIM properties
KIM_PROPERTIES, PROPERTY_NAME_TO_PROPERTY_ID, \
PROPERTY_ID_TO_PROPERTY_NAME = unpickle_kim_properties()
PROPERTY_ID_TO_PROPERTY_NAME = unednify_kim_properties()

NEW_PROPERTY_IDS = None
"""list: Newly added property IDs """


def get_properties():
"""Get the kim properties object hierarchy from the pickled object.
"""Get the kim properties object hierarchy from the edn object.
Returns:
dict -- KIM_PROPERTIES.
Expand Down Expand Up @@ -116,7 +116,7 @@ def kim_property_create(instance_id, property_name, property_instances=None):
Returns:
string -- serialized KIM-EDN formatted property instances.
"""
""" # noqa: E501
global KIM_PROPERTIES
global PROPERTY_NAME_TO_PROPERTY_ID
global PROPERTY_ID_TO_PROPERTY_NAME
Expand Down Expand Up @@ -168,13 +168,11 @@ def kim_property_create(instance_id, property_name, property_instances=None):
# Check to make sure that this property does not exist in OpenKIM
if _property_id in KIM_PROPERTIES:
msg = 'the input property_name file contains a property ID:\n'
msg += '"{}"\nwhich already '.format(_property_id)
msg += 'exists in the KIM Property Definition list.\n'
msg += 'Use the KIM Property Definition or update the ID in the'
msg += 'property_name file.\n'
msg += 'See the KIM Property Definitions at '
msg += 'https://openkim.org/properties for more detailed '
msg += 'information.'
msg += f'"{_property_id}"\nwhich already exists in the KIM '
msg += 'Property Definition list.\nUse the KIM Property '
msg += 'Definition or update the ID in the property_name '
msg += 'file.\nSee the KIM Property Definitions at https://'
msg += 'openkim.org/properties for more detailed information.'
raise KIMPropertyError(msg)

# Add the new property definition to KIM_PROPERTIES
Expand Down Expand Up @@ -203,13 +201,10 @@ def kim_property_create(instance_id, property_name, property_instances=None):
elif property_name in kim_property_ids:
new_property_instance["property-id"] = property_name
else:
msg = 'the requested "property_name" :\n'
msg += '"{}"\n'.format(property_name)
msg += 'is not a valid KIM property name nor '
msg += 'a path-like object to a file.\n'
msg += 'See the KIM Property Definitions at '
msg += 'https://openkim.org/properties for more detailed '
msg += 'information.'
msg = f'the requested "property_name" :\n"{property_name}"\nis not'
msg += ' a valid KIM property property name nor a path-like object'
msg += ' to a file.\nSee the KIM Property Definitions at https://'
msg += 'openkim.org/properties for more detailed information.'
raise KIMPropertyError(msg)

new_property_instance["instance-id"] = instance_id
Expand Down
Loading

0 comments on commit 4cd5b20

Please sign in to comment.