Skip to content

Commit

Permalink
Convert files with do2sunix
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Nov 21, 2022
1 parent 422ce75 commit d9f49a0
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 316 deletions.
18 changes: 9 additions & 9 deletions .ci_support/pypi_vs_conda_names.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"tables": "pytables",
"pyiron-base": "pyiron_base",
"pyiron-atomistics": "pyiron_atomistics",
"pyiron-contrib": "pyiron_contrib",
"pyiron-experimental": "pyiron_experimental",
"pyiron-continuum": "pyiron_continuum",
"pyiron-gpl": "pyiron_gpl",
"pyiron-gui": "pyiron_gui"
{
"tables": "pytables",
"pyiron-base": "pyiron_base",
"pyiron-atomistics": "pyiron_atomistics",
"pyiron-contrib": "pyiron_contrib",
"pyiron-experimental": "pyiron_experimental",
"pyiron-continuum": "pyiron_continuum",
"pyiron-gpl": "pyiron_gpl",
"pyiron-gui": "pyiron_gui"
}
144 changes: 72 additions & 72 deletions .ci_support/update_environment.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

import json
import re
import sys

import yaml

environment_file = '.ci_support/environment.yml'
name_mapping_file = '.ci_support/pypi_vs_conda_names.json'


class EnvironmentUpdater:
def __init__(self, package_name, from_version, to_version):
"""
Updates the version of a package in the conda environment file.
Parameters:
package_name: Name of the package to update as available on PyPI
from_version: Version the package is before the update
to_version: Version to which the package should be updated
"""
self.from_version = from_version
self.to_version = to_version
with open(name_mapping_file, 'r') as f:
self._name_conversion_dict = json.load(f)

with open(environment_file, 'r') as f:
self.environment = yaml.safe_load(f)

self.package_name = self._convert_package_name(package_name)

def _convert_package_name(self, name):
if name in self._name_conversion_dict.keys():
result = self._name_conversion_dict[name]
else:
result = name
return result

def _update_dependencies(self):
updated_dependencies = []

for dep in self.environment['dependencies']:
updated_dependencies.append(re.sub(
r'(' + self.package_name + '.*)' + self.from_version,
r'\g<1>' + self.to_version,
dep
))

self.environment['dependencies'] = updated_dependencies

def _write(self):
with open(environment_file, 'w') as f:
yaml.safe_dump(self.environment, f)

def update_dependencies(self):
"""Update the version of the requested dependency in the environment file"""
self._update_dependencies()
self._write()


if len(sys.argv) != 7 or not (sys.argv[1] == 'Bump' and sys.argv[3] == 'from' and sys.argv[5] == 'to'):
raise ValueError(f"Title of a dependabot PR 'Bump <package> from <version> to <version>' expected, "
f"but got {' '.join(sys.argv[1:])}")
package_to_update = sys.argv[2]
from_version = sys.argv[4]
to_version = sys.argv[6]

updater = EnvironmentUpdater(package_to_update, from_version, to_version)
updater.update_dependencies()
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

import json
import re
import sys

import yaml

environment_file = '.ci_support/environment.yml'
name_mapping_file = '.ci_support/pypi_vs_conda_names.json'


class EnvironmentUpdater:
def __init__(self, package_name, from_version, to_version):
"""
Updates the version of a package in the conda environment file.
Parameters:
package_name: Name of the package to update as available on PyPI
from_version: Version the package is before the update
to_version: Version to which the package should be updated
"""
self.from_version = from_version
self.to_version = to_version
with open(name_mapping_file, 'r') as f:
self._name_conversion_dict = json.load(f)

with open(environment_file, 'r') as f:
self.environment = yaml.safe_load(f)

self.package_name = self._convert_package_name(package_name)

def _convert_package_name(self, name):
if name in self._name_conversion_dict.keys():
result = self._name_conversion_dict[name]
else:
result = name
return result

def _update_dependencies(self):
updated_dependencies = []

for dep in self.environment['dependencies']:
updated_dependencies.append(re.sub(
r'(' + self.package_name + '.*)' + self.from_version,
r'\g<1>' + self.to_version,
dep
))

self.environment['dependencies'] = updated_dependencies

def _write(self):
with open(environment_file, 'w') as f:
yaml.safe_dump(self.environment, f)

def update_dependencies(self):
"""Update the version of the requested dependency in the environment file"""
self._update_dependencies()
self._write()


if len(sys.argv) != 7 or not (sys.argv[1] == 'Bump' and sys.argv[3] == 'from' and sys.argv[5] == 'to'):
raise ValueError(f"Title of a dependabot PR 'Bump <package> from <version> to <version>' expected, "
f"but got {' '.join(sys.argv[1:])}")
package_to_update = sys.argv[2]
from_version = sys.argv[4]
to_version = sys.argv[6]

updater = EnvironmentUpdater(package_to_update, from_version, to_version)
updater.update_dependencies()
60 changes: 30 additions & 30 deletions .github/workflows/UpdateDependabotPR.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: UpdateDependabotPR

on:
pull_request_target:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
if: (github.actor == 'dependabot[bot]')
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
- name: UpdateEnvironmentFile
shell: bash -l {0}
run: |
python .ci_support/update_environment.py ${{ github.event.pull_request.title }}
- name: UpdateDependabotPR commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "pyiron-runner"
git commit -m "[dependabot skip] Update environment" -a
- name: UpdateDependabotPR push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
name: UpdateDependabotPR

on:
pull_request_target:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
if: (github.actor == 'dependabot[bot]')
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }} # Check out the head of the actual branch, not the PR
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
- name: UpdateEnvironmentFile
shell: bash -l {0}
run: |
python .ci_support/update_environment.py ${{ github.event.pull_request.title }}
- name: UpdateDependabotPR commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "pyiron-runner"
git commit -m "[dependabot skip] Update environment" -a
- name: UpdateDependabotPR push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEPENDABOT_WORKFLOW_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
152 changes: 76 additions & 76 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
Loading

0 comments on commit d9f49a0

Please sign in to comment.