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

Update readme #5

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# pip install main
pip install --no-deps .
# Note: This produces build and pyiron_module_template.egg-info directories
# Note: This produces build and elaston.egg-info directories

# clean up
if [ -d "notebooks" ]; then
mv notebooks/* .
fi
if [ -d "${HOME}/pyiron_module_template" ]; then
if [ -d "${HOME}/elaston" ]; then
rm -r ${HOME}/.binder \
${HOME}/.ci_support \
${HOME}/.github \
${HOME}/build \
${HOME}/docs \
${HOME}/notebooks \
${HOME}/pyiron_module_template \
${HOME}/pyiron_module_template.egg-info \
${HOME}/elaston \
${HOME}/elaston.egg-info \
${HOME}/tests \
${HOME}/.gitattributes \
${HOME}/.gitignore \
Expand Down
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .coveragerc to control coverage.py
[run]
source = pyiron_module_template
omit = pyiron_module_template/_version.py
source = elaston
omit = elaston/_version.py
concurrency = multiprocessing
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyiron_module_template/_version.py export-subst
elaston/_version.py export-subst
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Create a bug report to help us eliminate issues and improve pyiron_module_template
about: Create a bug report to help us eliminate issues and improve elaston
title: ''
labels: bug
assignees: ''
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Feature request
about: Make a suggestion for a new feature or a change to pyiron_module_template
about: Make a suggestion for a new feature or a change to elaston
title: ''
labels: enhancement
assignees: ''
Expand All @@ -13,7 +13,7 @@ assignees: ''

**Detailed Description**

<!--Please explain how you would like to see pyiron_module_template enhanced, what feature(s) you are looking for, what specific problems this will solve.-->
<!--Please explain how you would like to see elaston enhanced, what feature(s) you are looking for, what specific problems this will solve.-->

**Further Information, Files, and Links**

Expand Down
131 changes: 41 additions & 90 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,63 @@
# pyiron_module_template

## Overview

This repository is a template for new pyiron modules similar to the existing modules of the
pyiron framework, e.g.
[pyiron_workflow](https://github.com/pyiron/pyiron_workflow),
[pyiron_ontology](https://github.com/pyiron/pyiron_ontology),
etc.

Within this repository, the new module is called `pyiron_module_template` which should be renamed to `pyiron_IntendedModuleName`.
This can be easily achieved by modifying and running `bash ./update_module_name.sh` script.

The licence is free to choose, but as a default the BSD3 licence packed here.

## Continuous Integration

We collect all files relevant for the continuous integration (CI) pipelines in `.ci_support`,
while the actual CI workflows are handled by GitHub and stored in `.github`.
If you are cloning this template *inside* the pyiron GitHub organization, the full CI should work out-of-the-box by calling reusable workflows from [pyiron/actions](github.com/pyiron/actions) and inheriting organization-wide secrets.
Otherwise, you will either need to modify the CI workflow files, or give your repository the following secrets:
- `DEPENDABOT_WORKFLOW_TOKEN` (GitHub token for an account that has permissions to your repository -- needs to differ from the default `github_token` already available though! In pyiron we have a special [@pyiron_runner account](https://github.com/pyiron-runner) for this purpose.)
- `PYPI_PASSWORD` (Token generated on PyPi to give access to your account there)
- `CODACY_PROJECT_TOKEN` (Token generated on Codacy to give access to your account there)

The default CI setup from [pyiron/actions](github.com/pyiron/actions) makes some assumptions about your directory structure.
The most important one is that your environment should be specified in `.ci_support/environment.yml`.
There is a base environment there already, giving dependence on `pyiron_base`.
The CI will automatically keep environment files read by readthedocs (which will look at `.readthedocs.yml`) and MyBinder (which looks in `.binder`) up-to-date based on this environment file.

In case you need extra environment files for some setups, you can modify the workflows in `.github/workflows`, which accept input variables for the docs, tests, and notebooks environments.
For example, it's typically good to not make your project depend on the `lammps` package, since this is not available for windows.
However, you might want to give some demo notebooks that run on MyBinder (a linux environment) and use LAMMPS calculations.
In this case, you could add a new file `.ci_support/environment-notebooks.yml`, and then edit `.github/workflows/push-pull.yml` so that instead of reading

```yaml
jobs:
pyiron:
uses: pyiron/actions/.github/workflows/[email protected]
secrets: inherit
# All the environment files variables point to .ci_support/environment.yml by default
```
# Elaston

It instead reads
Elaston is a simple and lightweight module for linear elasticity calculations.

```yaml
jobs:
pyiron:
uses: pyiron/actions/.github/workflows/[email protected]
secrets: inherit
with:
notebooks-env-files: .ci_support/environment.yml .ci_support/environment-notebooks.yml
```
## Installation

Where `.ci_support/environment-notebooks.yml` looks like:
We will offer pip and conda at some point. For now, you can install the package by cloning the repository and running the following command in the root directory:

```yaml
channels:
- conda-forge
dependencies:
- lammps
```bash
pip install .
```

### Dependencies
## Features

The CI for making new releases expects all the `pyproject.toml` dependencies to be fully specified with `==` and the conda dependencies to have their versions specified by `=`, i.e. precisely specifying the version the code here is intended to run on.
At release time, these dependencies can be relaxed so that new users installing your code may have access to a wider variety of environment possibilities.
For exact details on this relaxation, check documentation in the [centralized CI](https://github.com/pyiron/actions).
- Calculation of elastic constants
- Stress strain field around dislocations using anisotropic elasticity
- Stress strain field around point defects

### Label-based CI

Some CI triggers when labels get applied to a PR.
In a new repository, you will need to define these labels:
- `format_black`: Runs black analyis and creates a bot-generated commit to fix any format violations
- `run_CodeQL`: Runs the external CodeQL analysis (expensive, only do at the end)
- `run_coverage`: Run all the tests in `tests` and use coveralls to generate a coverage report (also expensive, only run near the end of your PR)
## Usage

## Documentation
Examples I: Get bulk modulus from the elastic tensor:

You should modify this README to reflect the purpose of your new package.
You can look at the other pyiron modules to get a hint for what sort of information to include, and how to link badges at the head of your README file.
```python
from elaston import LinearElasticity

At a minimum, we suggest creating a meaningful example notebook in the `notebooks/` directory and creating a MyBinder badge so that people can quickly and easily explore your work.
medium = LinearElasticity(elastic_tensor)
print(medium.bulk_modulus)
```

You can also edit the docs for your package by modifying `docs/index.rst`.
By default, this README is used as the landing page, and a simple API section is automatically generated.

## Tests
Example II: Get strain field around a point defect:

There is space for "benchmark", "integration", and "unit" tests in the `tests/` directory, with dummy tests for each.
These are run by the default CI, so modify them to suit your needs.
```python
import numpy as np
medium = LinearElasticity(elastic_tensor)
random_positions = np.random.random((10, 3))-0.5
dipole_tensor = np.eye(3)
print(medium.get_point_defect_strain(random_positions, dipole_tensor))
```

Additionally, the standard CI will attempt to execute all notebooks in the `notebooks/` directory.
See [`pyiron/actions`](https://github.com/pyiron/actions) and the reusable workflows there to learn about modifying the environment for the CI, e.g. to use a different env for notebook runs than for the tests in `tests/`.

Finally, `tests/integration/test_readme.py` shows how example code in the documentation gets tested against its claimed output.
E.g. if you change this:
Example III: Get stress field around a dislocation:

```python
>>> print(2 + 2)
4

import numpy as np
medium = LinearElasticity(elastic_tensor)
random_positions = np.random.random((10, 3))-0.5
burgers_vector = np.array([0, 0, 1])
print(medium.get_dislocation_stress(random_positions, burgers_vector))
```

To read `5` instead, those tests should fail.

## Publishing your package

If you are inside the pyiron organization or have your own `PYPI_PASSWORD` secret configured, your package will be published on PyPI automatically when you make a new "release" on GitHub -- *as long as* that tag matches the pattern specified in `setup.cfg`; by default any tag that `pyiron_module_template-`, where `pyiron_module_template` is replaced with the name of your module. We recommend using semantic versioning so that your first release looks like `pyiron_module_template-0.0.1`.
Example IV: Estimate the distance between partial dislocations:

Releasing your package on Conda-Forge is slightly more involved, but not too hard (at least for pure python packages).
See [conda-forge/staged-recipes](https://github.com/conda-forge/staged-recipes) for how to publish it there.
```python
medium = LinearElasticity(elastic_tensor)
partial_one = np.array([-0.5, 0, np.sqrt(3)/2])*lattice_constant
partial_two = np.array([0.5, 0, np.sqrt(3)/2])*lattice_constant
distance = 100
stress_one = medium.get_dislocation_stress([0, distance, 0], partial_one)
print('Choose `distance` in the way that the value below corresponds to SFE')
medium.get_dislocation_force(stress_one, [0, 1, 0], partial_two)
```
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. pyiron_module_template documentation master file
.. elaston documentation master file

.. _index:

Expand Down
26 changes: 0 additions & 26 deletions update_module_name.sh

This file was deleted.

Loading