From 47ff3b8a717942c13b528e39cda35bd97b1119b7 Mon Sep 17 00:00:00 2001 From: MartinBelthle Date: Tue, 26 Nov 2024 18:00:08 +0100 Subject: [PATCH] chore(release): prepare first release (#15) --- README.md | 39 +++---------------------- docs/CHANGELOG.md | 4 +++ docs/developer.md | 35 ++++++++++++++++++++++ docs/usage.md | 43 ++++++++++++++++++++++++++++ pyproject.toml | 7 ++--- sonar-project.properties | 4 +-- tests/integration/test_web_client.py | 5 +--- 7 files changed, 92 insertions(+), 45 deletions(-) create mode 100644 docs/CHANGELOG.md create mode 100644 docs/developer.md create mode 100644 docs/usage.md diff --git a/README.md b/README.md index d3b49718..07633e24 100644 --- a/README.md +++ b/README.md @@ -8,39 +8,8 @@ antares studies. This project only supports antares studies with a version v8.8 or higher. -## developers -### install dev requirements +**Table of Contents** -Install dev requirements with `pip install -r requirements-dev.txt` - -### linting and formatting - -To reformat your code, use this command line: `ruff check src/ tests/ --fix && ruff format src/ tests/` - -### typechecking - -To typecheck your code, use this command line: `mypy` - -### integration testing - -To launch integration tests you'll need an AntaresWebDesktop instance on your local env (at least the v.2.17.3, -**currently running in 2.17.5**). -To install it, download it from the last [Antares Web release](https://github.com/AntaresSimulatorTeam/AntaREST/releases) -(inside the assets list). -Then, unzip it at the root of this repository and rename the folder `AntaresWebDesktop`. -*NB*: The expected folder structure is the following: `antares_craft/AntaresWebDesktop/config.yaml` - -### tox -To use [tox](https://tox.wiki/) to run unit tests in multiple python versions at the same time as linting and formatting -with ruff and typing with mypy: -1) As the dev requirements include [uv](https://docs.astral.sh/uv/) and `tox-uv` there is no need to install python -versions, `uv` will do this for you. -2) Use `tox -p` to run the environments in parallel to save time, this will create virtual environment with the -necessary python versions the first time you run tox. - -### mkdocs -Smallest beginning of `mkdocs` included more as proof of concept than anything, theme and logo copied from [Antares -Simulator](https://github.com/AntaresSimulatorTeam/Antares_Simulator). -1) To preview the docs on your local machine run `mkdocs serve`. -2) To build the static site for publishing for example on [Read the Docs](https://readthedocs.io) use `mkdocs build`. -3) To flesh out the documentation see [mkdoc guides](https://www.mkdocs.org/user-guide/). +- [usage](docs/usage.md) +- [development](docs/developer.md) +- [Changelog](docs/CHANGELOG.md) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md new file mode 100644 index 00000000..54b47843 --- /dev/null +++ b/docs/CHANGELOG.md @@ -0,0 +1,4 @@ +v0.1.0 (2024-11-26) +------------------- + +* First release of the project. \ No newline at end of file diff --git a/docs/developer.md b/docs/developer.md new file mode 100644 index 00000000..1d915348 --- /dev/null +++ b/docs/developer.md @@ -0,0 +1,35 @@ +### install dev requirements + +Install dev requirements with `pip install -r requirements-dev.txt` + +### linting and formatting + +To reformat your code, use this command line: `ruff check src/ tests/ --fix && ruff format src/ tests/` + +### typechecking + +To typecheck your code, use this command line: `mypy` + +### integration testing + +To launch integration tests you'll need an AntaresWebDesktop instance on your local env (at least the v.2.17.3, +**currently running in 2.17.5**). +To install it, download it from the last [Antares Web release](https://github.com/AntaresSimulatorTeam/AntaREST/releases) +(inside the assets list). +Then, unzip it at the root of this repository and rename the folder `AntaresWebDesktop`. +*NB*: The expected folder structure is the following: `antares_craft/AntaresWebDesktop/config.yaml` + +### tox +To use [tox](https://tox.wiki/) to run unit tests in multiple python versions at the same time as linting and formatting +with ruff and typing with mypy: +1) As the dev requirements include [uv](https://docs.astral.sh/uv/) and `tox-uv` there is no need to install python +versions, `uv` will do this for you. +2) Use `tox -p` to run the environments in parallel to save time, this will create virtual environment with the +necessary python versions the first time you run tox. + +### mkdocs +Smallest beginning of `mkdocs` included more as proof of concept than anything, theme and logo copied from [Antares +Simulator](https://github.com/AntaresSimulatorTeam/Antares_Simulator). +1) To preview the docs on your local machine run `mkdocs serve`. +2) To build the static site for publishing for example on [Read the Docs](https://readthedocs.io) use `mkdocs build`. +3) To flesh out the documentation see [mkdoc guides](https://www.mkdocs.org/user-guide/). diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 00000000..b9a895bb --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,43 @@ +# Introduction + +With antares-craft you can interact with studies using AntaresWeb API or in local mode. +To interact with AntaresWeb you need a token. + +## AntaresWeb + +### How to create a study + +``` +api_config = APIconf(api_host=antares_web.url, token=your_token, verify=False) +study = create_study_api("antares-craft-test", "880", api_config) +``` + +### How to point to an existing study + +Not handled yet + +## LOCAL + +### How to create a study + + study = create_study_local("your_name", 880, {"local_path": "your_path", "study_name": "your_name"}) + +### How to point to an existing study + +`study = read_study_local(study_path)` + +## Apart from that every operation is the same no matter the environment you're targetting. + +### How to create an area with given properties: + +``` +area_properties = AreaProperties() +area_properties.energy_cost_unsupplied = 10 +study.create_area("fr", area_properties) +``` + +### How to access study areas + +``` +area_list = study.read_areas() +``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4b611495..9251abca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,15 +4,14 @@ build-backend = "setuptools.build_meta" [project] name = "antares_craft" -version = "0.0.1" -description = """Antares Craft python library is currently under construction. When completed it will allow to \ -create, update and read antares studies.""" +version = "0.1.0" +description = """Antares Craft python library under construction. It will allow to create, update and read antares studies.""" readme = "README.md" license = {file = "LICENSE"} authors = [ {name="Sylvain Leclerc"}, {name="Tatiana Vargas"}, - {name="Martin Behlthle"}, + {name="Martin Belthle"}, {name="Sigurd Borge"} ] requires-python = ">=3.9" diff --git a/sonar-project.properties b/sonar-project.properties index 72ec04f6..a4f7b575 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ -sonar.projectVersion=0.1.5 +sonar.projectVersion=0.1.0 sonar.organization=antaressimulatorteam sonar.projectKey=AntaresSimulatorTeam_antares_craft sonar.sources=src sonar.language=python sonar.python.coverage.reportPaths=coverage.xml -sonar.python.version=3.9 \ No newline at end of file +sonar.python.version=3.11 \ No newline at end of file diff --git a/tests/integration/test_web_client.py b/tests/integration/test_web_client.py index 69ddde87..ea54ec51 100644 --- a/tests/integration/test_web_client.py +++ b/tests/integration/test_web_client.py @@ -32,7 +32,6 @@ from antares.model.st_storage import STStorageGroup, STStorageMatrixName, STStorageProperties from antares.model.study import create_study_api from antares.model.thermal import ThermalClusterGroup, ThermalClusterProperties -from antares.service.api_services.area_api import AreaApiService from tests.integration.antares_web_desktop import AntaresWebDesktop @@ -52,8 +51,6 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop): study = create_study_api("antares-craft-test", "880", api_config) - area_api = AreaApiService(api_config, study.service.study_id) - # tests area creation with default values area_name = "FR" area_fr = study.create_area(area_name) @@ -196,7 +193,7 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop): assert properties.group == STStorageGroup.BATTERY # test reading list of areas - area_list = area_api.read_areas() + area_list = study.read_areas() assert len(area_list) == 3 # asserts areas are sorted by id assert area_list[0].id == area_be.id