Skip to content

Commit

Permalink
Prepare for v0.5.2 (#102)
Browse files Browse the repository at this point in the history
* bump to v0.5.2

* change readme & changelog to markdown from rst

* tell pyproject that readme is now markdown
  • Loading branch information
vtnate authored Oct 30, 2024
1 parent d92e8c8 commit 45abe8b
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 223 deletions.
98 changes: 44 additions & 54 deletions CHANGELOG.rst → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
=========
Changelog
=========
# Changelog

Version 0.5.2-rc3
=================

What's Changed
--------------
* Add from_list method to create an MOS file by @nllong in https://github.com/urbanopt/modelica-builder/pull/100


Version 0.5.2-rc2
=================

What's Changed
--------------
* Update GitHub action versions by @nllong in https://github.com/urbanopt/modelica-builder/pull/97
* Parse Modelica parameters with non-primitive types by @vtnate in https://github.com/urbanopt/modelica-builder/pull/98


Version 0.5.2-rc1
=================

What's Changed
--------------

* Add Modelica measure base classes in https://github.com/urbanopt/modelica-builder/pull/76
## Version 0.5.2
### What's Changed
* Add get method for a component's argument by @nllong in https://github.com/urbanopt/modelica-builder/pull/57
* Update README.rst by @nllong in https://github.com/urbanopt/modelica-builder/pull/58
* build(deps): bump pygments from 2.12.0 to 2.15.0 by @dependabot in https://github.com/urbanopt/modelica-builder/pull/60
* Add extends redeclare update method by @nllong in https://github.com/urbanopt/modelica-builder/pull/59
* Add method for getting and setting parameters by @nllong in https://github.com/urbanopt/modelica-builder/pull/61
* Bump version and update test dependencies by @nllong in https://github.com/urbanopt/modelica-builder/pull/62
* update _source filename when calling save_as by @nllong in https://github.com/urbanopt/modelica-builder/pull/64
* update deprecated import statements by @vtnate in https://github.com/urbanopt/modelica-builder/pull/65
* Add poetry and remove tox by @nllong in https://github.com/urbanopt/modelica-builder/pull/67
* Move Modelica methods over from GMT by @nllong in https://github.com/urbanopt/modelica-builder/pull/68
* Update antlr4 and use a non-deprecated docker base image by @vtnate in https://github.com/urbanopt/modelica-builder/pull/66
* Update changelog by @nllong in https://github.com/urbanopt/modelica-builder/pull/70
* Support py312 by @vtnate in https://github.com/urbanopt/modelica-builder/pull/73
* Add method to scale loads in an MOS file by @nllong in https://github.com/urbanopt/modelica-builder/pull/74
* Bump version of antlr runtime to 4.13.1 by @nllong in https://github.com/urbanopt/modelica-builder/pull/75
* Add `.mpignore` to skip loading files in ModelicaProject by @nllong in https://github.com/urbanopt/modelica-builder/pull/77
* Upgrade to MBLv10 by @vtnate in https://github.com/urbanopt/modelica-builder/pull/72
* Update copyright dates by @nllong in https://github.com/urbanopt/modelica-builder/pull/80
* Prepare for v0.5.0 release by @vtnate in https://github.com/urbanopt/modelica-builder/pull/79
* Ensure the correct template is loaded when parsing the package by @vtnate in https://github.com/urbanopt/modelica-builder/pull/81
* Create config file to automatically publish to pypi when a Github release is made by @vtnate in https://github.com/urbanopt/modelica-builder/pull/82
* build(deps): bump jinja2 from 3.1.2 to 3.1.3 by @dependabot in https://github.com/urbanopt/modelica-builder/pull/84
* build(deps-dev): bump requests from 2.31.0 to 2.32.0 by @dependabot in https://github.com/urbanopt/modelica-builder/pull/87
* Add Modelica measure base classes by @nllong in https://github.com/urbanopt/modelica-builder/pull/76
* Update certifi and jinja by @nllong in https://github.com/urbanopt/modelica-builder/pull/94
* Prep 0.5.2-rc2 release by @nllong in https://github.com/urbanopt/modelica-builder/pull/95
* Update GitHub action versions by @nllong in https://github.com/urbanopt/modelica-builder/pull/97
* Parse Modelica parameters with non-primitive types by @vtnate in https://github.com/urbanopt/modelica-builder/pull/98
* Add from_list method to create an MOS file by @nllong in https://github.com/urbanopt/modelica-builder/pull/100


**Full Changelog**: https://github.com/urbanopt/modelica-builder/compare/v0.5.1...v0.5.2-rc1
**Full Changelog**: https://github.com/urbanopt/modelica-builder/compare/v0.5.1...v0.5.2

Version 0.5.1
=============
## Version 0.5.1

What's Changed
--------------
### What's Changed

* Ensure the correct template is loaded when parsing the package by @vtnate in https://github.com/urbanopt/modelica-builder/pull/81
* Create config file to automatically publish to pypi when a Github release is made by @vtnate in https://github.com/urbanopt/modelica-builder/pull/82

**Full Changelog**: https://github.com/urbanopt/modelica-builder/compare/v0.5.0...v0.5.1

Version 0.5.0
=============
## Version 0.5.0

What's Changed
--------------
### What's Changed

* Support py312 by @vtnate in https://github.com/urbanopt/modelica-builder/pull/73
* Add method to scale loads in an MOS file by @nllong in https://github.com/urbanopt/modelica-builder/pull/74
Expand All @@ -58,11 +57,9 @@ What's Changed

**Full Changelog**: https://github.com/urbanopt/modelica-builder/compare/v0.4.0...v0.5.0

Version 0.4.0
=============
## Version 0.4.0

What's Changed
--------------
### What's Changed

* Add get method for a component's argument by @nllong in https://github.com/urbanopt/modelica-builder/pull/57
* Update README.rst by @nllong in https://github.com/urbanopt/modelica-builder/pull/58
Expand All @@ -81,8 +78,7 @@ What's Changed

**Full Changelog**: https://github.com/urbanopt/modelica-builder/compare/v0.3.0...v0.4.0

Version 0.3.0
=============
## Version 0.3.0

* bump version and copyright dates by @nllong in https://github.com/urbanopt/modelica-builder/pull/55
* Add get method for a component's argument by @nllong in https://github.com/urbanopt/modelica-builder/pull/57
Expand All @@ -91,38 +87,32 @@ Version 0.3.0
* Add extends redeclare update method by @nllong in https://github.com/urbanopt/modelica-builder/pull/59
* Add method for getting and setting parameters by @nllong in https://github.com/urbanopt/modelica-builder/pull/61

Version 0.2.3
=============
## Version 0.2.3

* Update precommit and ci by @nllong in https://github.com/urbanopt/modelica-builder/pull/54
* Update overwrite_component_redeclaration to handle the redeclare of args by @nllong in https://github.com/urbanopt/modelica-builder/pull/53

Version 0.2.2
=============
## Version 0.2.2

* Add component argument/parameter deletion, remove_component_argument
* Add test for deleting a "constant Integer x=5" component
* Update testing dependencies
* Add component redeclare package argument replacement

Version 0.2.1
=============
## Version 0.2.1

* Fix import issue when installing package for a poetry-managed projects

Version 0.2.0
=============
# Version 0.2.0

* Fix compatibility with files containing '\r\n', which is typically used on Windows

Version 0.1.1
=============
## Version 0.1.1

* Add ability to rename a component's argument name
* Convert to use GitHub actions instead of Travis
* Update README with more practical example

Version 0.1.0
=============
## Version 0.1.0

* Initial release
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Modelica Builder

The Modelica Builder project aims to make in-place modifications to Modelica language files easier.
The principal use case is to load, modify using higher level abstracted methods, and then save the
resulting file. The user has access to the entire Abstract Syntax Tree of the entire Modelica grammar.

The Modelica Builder project does not:

* Compile nor check for syntax validity

## Install

`pip install modelica-builder`

## Usage

ModBuild provides specific methods for reading and modifying files.

```python
from modelica_builder.model import Model

# parse the model file
source_file = 'DCMotor.mo'
model = Model(source_file)

# do read and modify the model
# refer to modelica_builder.model.Model class methods to see what's available
name = model.get_name()
model.set_name('New' + name)
model.add_connect('some.component.port_a', 'another.component.port_b')
model.insert_component('MyComponentType', 'myInst',
modifications={'arg1': '1234'}, string_comment='my comment',
annotations=['my annotation'], insert_index=0)

# save the result
model.save_as('NewDCMotor.mo')
```

You can also define your own classes for editing the file

```python
from modelica_builder.edit import Edit
from modelica_builder.selector import Selector
from modelica_builder.transformation import SimpleTransformation

class MySelector(Selector):
# implement class for selecting AST nodes

# define the edit to make to the node's text and combine it with the selector
edit = Edit.make_replace('FOOBAR')
selector = MySelector()
transformation = SimpleTransformation(selector, edit)

model = Model('my_modelica_file.mo')
# add your custom transformation
model.add(transformation)
model.save_as('result.mo')
```

Transformations specify what nodes to change and how to change them. This is done by combining
Selectors and Edits. Selectors specify how to select nodes in the AST, and edits are modifications
(insert, replace, delete) to the text of selected nodes.

A Transformer is a collection of Transformations, which can then be applied to a file.

See the tests for more examples and information.

## Development

For developers, dependency management is through [Poetry](https://python-poetry.org/docs/). Installation is accomplished by running `pip install poetry`.

```bash
pip install poetry

# install after cloning repo
poetry install
```

If you change the source grammar file you need to regenerate the parser and lexer.

With docker installed, run these commands from this the repo's root directory

```bash
# build Antlr container
docker build -t antlr4:latest -f antlr/Dockerfile .

# run parser generator for python
docker run -v "$(pwd)/modelica_builder/modelica_parser":/var/antlrResult \
antlr4:latest \
-Dlanguage=Python3 /var/antlrResult/modelica.g4

# commit results along with grammar file
```

If not using Docker, install antlr4 following [these instructions](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md#installation).

```bash
# in modelica_building/modelica_parser
antlr4 -Dlanguage=Python3 modelica.g4

# commit results along with grammar file
```

## Managed Tasks

### Updating Licenses

To apply the copyright/license to all the files, run the following managed task. To update, then update the
script, and then rerun the managed task.

```bash
./setup.py update_licenses
```

### Testing

To run the tests, simply run the following:

```bash
poetry run pytest
```
### Known Issues

* The transformations occur on strings which are immutable. Need to investigate using byte arrays. This does not cause errors, but can be slow when parsing really large modelica files.

## Release Instructions

1. Bump version to <NEW_VERSION> in pyproject.toml (use semantic versioning, e.g., 0.5.0, 0.5.1.rc1).
1. Run `poetry run pre-commit --all-files`
1. In a prep-release branch, push the changes to GitHub and draft a release against the latest branch.
* Run 'auto-generate changelog' and copy the contents to the CHANGELOG.md. Cull any items that are repeated.
* Discard the draft release (you will create an official one off of the main branch later)
1. Merge the prep-release branch into develop.
1. From command line, merge develop into main with: `git checkout main; git pull; git merge --ff-only origin develop; git push`
1. In GitHub, tag the release against main. Copy and paste the changelog entry into the notes. Verify the release is posted to PyPI.
Loading

0 comments on commit 45abe8b

Please sign in to comment.