Skip to content

Commit

Permalink
Ci/change release trigger (#29)
Browse files Browse the repository at this point in the history
* Fix bot aliases in .mailmap (tardis-sn#2038)

* Added v_inner and v_outer, enable_nonhomologous_expansion for future use in nonhomologous expansion (tardis-sn#2024)

* added v_outer and v_inner to NumbaModel

* defined default value for v_inner and v_outer in NumbaModel

* added enable_nonhomologous_expansion to io/schemas/montecarlo.yml

* added v_inner and v_outer to NumbaPlasma

* added v_inner and v_outer as arguments for NumbaModel in run() in montecarlo_numba

* added v_outer_cgs to MonteCarloRunner

* removed a comment

* ran black on the changed files

* added right arguments in test

* added v_inner, v_outer to tests

* added temporary fix to formal_integral.py

* ran black on modified files

* changed dummy values in the test

* Reverted content of file.

* made needed change in test_cuda_formal_integral.py

* made needed change in test_numba_formal_integral.py

* Update README.rst in post-release (tardis-sn#2037)

* Fix docs badge

* Add license badge

* First attempt of creating credits.rst and README.rst via templates

* Working version

* Restore old README.rst

* Update post-release workflow

* Change .gitignore

* Various fixes

* Check PEP8 on CI (tardis-sn#2039)

* Add Flake8 job

* Change to file description

* Test payload

Co-authored-by: Sona Chitchyan <[email protected]>
  • Loading branch information
epassaro and sonachitchyan authored Jun 2, 2022
1 parent af5ff83 commit 2a15557
Show file tree
Hide file tree
Showing 19 changed files with 264 additions and 90 deletions.
77 changes: 77 additions & 0 deletions .ci-helpers/update_credits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""Script for updating `credits.rst` and `README.rst` between releases,
requires the `rst-include` package"""

import pathlib
import re
import textwrap
import warnings

import requests
from rst_include import rst_include


def generate_zenodo():
"""Generates `zenodo.rst` file with BibTeX citation
Adapted from: https://astrodata.nyc/posts/2021-04-23-zenodo-sphinx/"""

CONCEPT_DOI = "592480" # See: https://help.zenodo.org/#versioning
zenodo_path = pathlib.Path("docs/resources/zenodo.rst")

try:
headers = {"accept": "application/x-bibtex"}
response = requests.get(
f"https://zenodo.org/api/records/{CONCEPT_DOI}", headers=headers
)
response.encoding = "utf-8"
citation = re.findall("@software{(.*)\,", response.text)
zenodo_record = (
f".. |ZENODO| replace:: {citation[0]}\n\n"
".. code-block:: bibtex\n\n"
+ textwrap.indent(response.text, " " * 4)
)

except Exception as e:
warnings.warn(
"Failed to retrieve Zenodo record for TARDIS: " f"{str(e)}"
)

not_found_msg = """
Couldn"t retrieve the TARDIS software citation from Zenodo. Get it
directly from `this link <https://zenodo.org/record/{CONCEPT_DOI}>`_ .
"""

zenodo_record = (
".. |ZENODO| replace:: <TARDIS SOFTWARE CITATION HERE> \n\n"
".. warning:: \n\n" + textwrap.indent(not_found_msg, " " * 4)
)

with open(zenodo_path, "w") as f:
f.write(zenodo_record)

print(zenodo_record)


def main():
generate_zenodo()

rst_include.include(
source="docs/resources/credits_template.rst",
target="docs/resources/credits.rst",
quiet=False,
inplace=False,
source_encoding="utf-8",
target_encoding="utf-8",
)

rst_include.include(
source="README_TEMPLATE.rst",
target="README.rst",
quiet=False,
inplace=False,
source_encoding="utf-8",
target_encoding="utf-8",
)


if __name__ == "__main__":
main()
30 changes: 0 additions & 30 deletions .github/workflows/black.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# For more information about TARDIS pipelines, please refer to:
#
# https://tardis-sn.github.io/tardis/development/continuous_integration.html

name: codestyle

on:
push:
branches:
- '*'

pull_request:
branches:
- '*'

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Black
run: pip install black==22.3

- name: Run Black
run: black --check tardis

flake8:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Flake8
run: pip install flake8==4.0.1 pep8-naming==0.12.1

- name: Run Flake8
run: flake8 tardis
13 changes: 13 additions & 0 deletions .github/workflows/payload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: payload

on:
push:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo $PAYLOAD
env:
PAYLOAD: ${{ github.event }}
29 changes: 28 additions & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v2

- name: Wait for Zenodo webhook
run: sleep 120
run: sleep 180

- name: Setup Python
uses: actions/setup-python@v3
Expand All @@ -57,6 +57,32 @@ jobs:
name: citation
path: CITATION.cff

credits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Wait for Zenodo webhook
run: sleep 180

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install rst-include
run: pip install rst-include requests

- name: Update README.rst
run: python .ci-helpers/update_credits.py

- uses: actions/upload-artifact@v3
with:
name: credits
path: |
README.rst
docs/resources/credits.rst
pull_request:
needs: [changelog, citation]
runs-on: ubuntu-latest
Expand All @@ -71,6 +97,7 @@ jobs:
run: |
cp /tmp/changelog/CHANGELOG.md .
cp /tmp/citation/CITATION.cff .
cp -r /tmp/credits/* .
- name: Get current date
run: echo "DATE=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ MANIFEST
# Sphinx
docs/api
docs/_build
docs/resources/ZENODO.rst
docs/tutorials.rst
docs/io/configuration/components/models/converters/density_parse.csv
docs/io/configuration/components/models/converters/abund_parse.csv
Expand Down
9 changes: 5 additions & 4 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ Stuart Sim <[email protected]> ssim <[email protected]>
Stuart Sim <[email protected]> Stuart Sim <[email protected]>
Stuart Sim <[email protected]> Stuart Sim <[email protected]>

tardis-bot <[email protected]>
tardis-bot <[email protected]> tardis-bot <[email protected]>
tardis-bot <[email protected]> tardis-bot <[email protected]>
tardis-bot <[email protected]> tardis-bot <[email protected]>
TARDIS Bot <[email protected]>
TARDIS Bot <[email protected]> tardis-bot <[email protected]>
TARDIS Bot <[email protected]> TARDIS Bot <[email protected]>
TARDIS Bot <[email protected]> TARDIS Bot <[email protected]>
TARDIS Bot <[email protected]> Azure Pipelines <[email protected]>

Tomas Bylund <[email protected]>
Tomas Bylund <[email protected]> Tobychev <[email protected]>
Expand Down
56 changes: 56 additions & 0 deletions README_TEMPLATE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
======
TARDIS
======

.. image:: https://img.shields.io/badge/Donate-to%20TARDIS-brightgreen.svg
:target: https://numfocus.salsalabs.org/donate-to-tardis/index.html

.. image:: https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A
:target: http://numfocus.org

.. image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://gitter.im/tardis-sn/tardis

.. image:: https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc
:target: https://open.vscode.dev/tardis-sn/tardis
|
TARDIS is a tool that creates synthetic observations (*spectra*) for exploding
stars (*supernovae*).

.. image:: https://codecov.io/gh/tardis-sn/tardis/branch/master/graph/badge.svg
:target: https://codecov.io/gh/tardis-sn/tardis

.. image:: https://img.shields.io/endpoint?url=https://jsonbin.org/tardis-bot/tardis/badges/docstr-cov
:target: https://github.com/tardis-sn/tardis/actions/workflows/docstr-cov.yml?query=branch%3Amaster

.. image:: https://github.com/tardis-sn/tardis/actions/workflows/tests.yml/badge.svg
:target: https://github.com/tardis-sn/tardis/actions/workflows/tests.yml

.. image:: https://github.com/tardis-sn/tardis/actions/workflows/build-docs.yml/badge.svg
:target: https://tardis-sn.github.io/tardis/index.html

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
|

.. include:: docs/resources/credits.rst


*******
License
*******

.. image:: https://img.shields.io/conda/l/conda-forge/tardis-sn
:target: https://github.com/tardis-sn/tardis/blob/master/licenses/LICENSE.rst

.. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat
:target: http://www.astropy.org
|
This project is Copyright (c) TARDIS Collaboration and licensed under
the terms of the BSD 3-Clause license. This package is based upon
the `Astropy package template <https://github.com/astropy/package-template>`_
which is licensed under the BSD 3-clause license. See the licenses folder for
more information.
48 changes: 1 addition & 47 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
# directories to ignore when looking for source files.
exclude_patterns.append("_templates")
exclude_patterns.append("_build")
exclude_patterns.append("**_template.rst")
exclude_patterns.append("**.ipynb_checkpoints")
exclude_patterns.append("resources/research_done_using_TARDIS/ads.ipynb")

Expand Down Expand Up @@ -334,54 +335,8 @@

# -- Sphinx hook-ins ---------------------------------------------------------

import re
import pathlib
import requests
import textwrap
import warnings
from shutil import copyfile


def generate_ZENODO(app):
"""Creating ZENODO.rst
Adapted from: https://astrodata.nyc/posts/2021-04-23-zenodo-sphinx/"""
CONCEPT_DOI = "592480" # See: https://help.zenodo.org/#versioning
zenodo_path = pathlib.Path("resources/ZENODO.rst")

try:
headers = {"accept": "application/x-bibtex"}
response = requests.get(
f"https://zenodo.org/api/records/{CONCEPT_DOI}", headers=headers
)
response.encoding = "utf-8"
citation = re.findall("@software{(.*)\,", response.text)
zenodo_record = (
f".. |ZENODO| replace:: {citation[0]}\n\n"
".. code-block:: bibtex\n\n"
+ textwrap.indent(response.text, " " * 4)
)

except Exception as e:
warnings.warn(
"Failed to retrieve Zenodo record for TARDIS: " f"{str(e)}"
)

not_found_msg = """
Couldn"t retrieve the TARDIS software citation from Zenodo. Get it
directly from `this link <https://zenodo.org/record/{CONCEPT_DOI}>`_ .
"""

zenodo_record = (
".. |ZENODO| replace:: <TARDIS SOFTWARE CITATION HERE> \n\n"
".. warning:: \n\n" + textwrap.indent(not_found_msg, " " * 4)
)

with open(zenodo_path, "w") as f:
f.write(zenodo_record)

print(zenodo_record)


def generate_tutorials_page(app):
"""Create tutorials.rst"""
notebooks = ""
Expand Down Expand Up @@ -434,7 +389,6 @@ def create_redirect_files(app, docname):


def setup(app):
app.connect("builder-inited", generate_ZENODO)
app.connect("builder-inited", generate_tutorials_page)
app.connect("autodoc-skip-member", autodoc_skip_member)
app.connect("build-finished", create_redirect_files)
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ The following BibTeX entries are needed for the references:
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
.. include:: ZENODO.rst
.. include:: zenodo.rst
4 changes: 4 additions & 0 deletions tardis/io/schemas/montecarlo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ properties:
default: false
description: Enables a more complete treatment of relativitic effects. This includes
angle aberration as well as use of the fully general Doppler formula.
enable_nonhomologous_expansion:
type: boolean
default: false
description: Enables nonhomologous expansion. Treats shells as piece-wise homologous areas for velocity-radius dependence.
tracking:
type: object
default: {}
Expand Down
1 change: 1 addition & 0 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def _initialize_geometry_arrays(self, model):
self.r_inner_cgs = model.r_inner.to("cm").value
self.r_outer_cgs = model.r_outer.to("cm").value
self.v_inner_cgs = model.v_inner.to("cm/s").value
self.v_outer_cgs = model.v_outer.to("cm/s").value

def _initialize_packets(self, T, no_of_packets, iteration, radius):
# the iteration is added each time to preserve randomness
Expand Down
Loading

0 comments on commit 2a15557

Please sign in to comment.