Skip to content

Commit

Permalink
Merge pull request #29 from tZ3ma/develop
Browse files Browse the repository at this point in the history
Hotfixes
  • Loading branch information
mathias-ammon authored Feb 28, 2023
2 parents cfcfcfb + 484e741 commit d7b5d92
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 56 deletions.
59 changes: 55 additions & 4 deletions docs/source/getting_started/initialization.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,61 @@
.. _init:

Plugin Initialization
Tessif Initialization
=====================
Initialize a supported tesisf pluging using tessif's cli. So for initializing
the tessif plugin ``tessif-pypsa-0-19-3``:
Initialize Tessif's main working directory via its command line interface:

.. code-block:: console
$ tessif init tessif-pypsa-0-19-3
$ tessif init
This creates Tessif's main directory at :file:`~/.tessif./'.
Plugin Integration
==================
Plugin integration can be done in two ways.
Command Line Interface
----------------------
Integrate a supported tessif pluging using tessif's cli for convenience.
For initializing the tessif plugin ``tessif-pypsa-0-19-3`` just use the
command:

.. code-block:: console
$ tessif integrate tessif-pypsa-0-19-3
This will add a :file:`~/.tessif.d/plugin-venvs/tessif-pypsa-0-19-3/' folder
hosting the ``venv`` required.

The plugins currently suited for this are:

- tessif-oemof
- tessif-pypsa

Manual Integration
------------------
In case the automated integration fails, or you wish to install the plugins
manually. Create a the ``venv`` environment for the plugin manually at the
required folder. So for ``tessif-fine-2-2-2`` this would be:

.. code-block:: console
$ python3.8 -m venv ~/.tessif.d/plugin-venvs/tessif-fine-2-2-2
$ source ~/.tessif.d/plugin-venvs/tessif-fine-2-2-2/bin/activate
$ pip install -U tessif-fine-2-2-2
This is currently required for:

tessif-fine-2-2-2
tessif-calliope-0-6-6post1

since they only support python3.8.

Note that tessif can support different python binaries, since it activates
the respective virtualenvironment before perfroming the plugin specific
transformation, optimization and post-processing. So tessif can be installed
using python 3.10, whereas some plugins can use e.g. 3.8.

If you decide to install tessif using python3.8, however, integration
using :code:`tessif integrate PLUGIN` is available for all plugins.
23 changes: 4 additions & 19 deletions docs/source/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@ Following Sections provide overview on how to install the package.
:local:


Standard
========

Linux
-----

Install using a console with your virtual environment activated:

Latest Stable Version
^^^^^^^^^^^^^^^^^^^^^
=====================
.. code-block:: console
$ pip install tessif
Latest Development Version (potentially unstable)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
=================================================

.. code-block:: console
Expand All @@ -43,7 +35,7 @@ Linux
-----

1. You need Python 3.8+ (Pyenv_ is hightly recommended for multiple verions)
2. Install Poetry_ and Nox_
2. Install Poetry_ and Nox_ and Nox-Poetry_
3. Clone the repo to a local directory (uses package name if square bracket
part is omitted):

Expand All @@ -64,17 +56,10 @@ Linux
$ poetry shell
6. (Optional) Alternatively, you can now run an interactive Python session, or
the command-line interface:

.. code:: console
$ poetry run python
$ poetry run tessif
.. _PyPI: https://pypi.org/
.. _TestPyPI: https://test.pypi.org/
.. _Poetry: https://python-poetry.org/
.. _Nox: https://nox.thea.codes/
.. _Pyenv: https://github.com/pyenv/pyenv
.. _Nox-Poetry: https://nox-poetry.readthedocs.io/en/stable/index.html
23 changes: 3 additions & 20 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,8 @@
"docs_rebuild",
)


# deprecated with migration to nox-poetry:
# def install_with_constraints(session, *args, **kwargs):
# """Install packages constrained by Poetry's lock file."""
# with tempfile.NamedTemporaryFile() as requirements:
# session.run(
# "poetry",
# "export",
# "--dev",
# "--format=requirements.txt",
# "--without-hashes", # requ for working with pip resolver
# f"--output={requirements.name}",
# external=True,
# )
# session.install(f"--constraint={requirements.name}", *args, **kwargs)
# locations to run linting and formatting on:
locations = "src", "tests", "noxfile.py", "docs/conf.py"


@nox_poetry.session(python="3.10")
Expand All @@ -49,7 +36,7 @@ def tests(session):
"not e2e and not con and not slow",
# append exlcuded markers as "and not ..."
]
session.run("poetry", "install", "--no-dev", external=True)
session.run("poetry", "install", "--only", "main", external=True)
session.install(
"tessif-examples",
"coverage[toml]",
Expand All @@ -60,10 +47,6 @@ def tests(session):
session.run("pytest", *args)


# locations to run linting and formatting on:
locations = "src", "tests", "noxfile.py", "docs/conf.py"


@nox_poetry.session(python="3.10")
def lint(session):
"""Lint using flake8."""
Expand Down
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "tessif"
version = "0.0.25"
description = "Transforming Energy Supply System modell*I*ng Framework"
authors = ["Mathias Ammon <mathias.ammon@tuhh.de>"]
authors = ["Mathias Ammon <tz3ma.coding@use.startmail.com>"]
license = "MIT"
readme = "README.rst"
repository = "https://github.com/tZ3ma/tessif"
Expand Down Expand Up @@ -37,6 +37,7 @@ sphinx-paramlinks = "^0.5.2"
pylint = "^2.14.5"
nox = "^2022.11.21"
nox-poetry = "^1.0.2"
tessif-examples = ">=0.3.0"

[tool.poetry.scripts]
tessif = "tessif.cli:main_cli_entry"
Expand Down
19 changes: 9 additions & 10 deletions src/tessif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,22 @@ def init(tessif_directory=None, dry=False):
"""Initialize tessif's working directory."""
if not tessif_directory:
tessif_directory = tessif_dir
elif tessif_directory == "~/.tessif.d/":
tessif_directory = tessif_dir

# Create a Path object for the new folder
working_directory = Path(tessif_directory)

logger.info(
"Attempting to initialize tessif's working directory at %s",
working_directory,
)
logging_directory = Path(os.path.join(tessif_directory, "logs"))

if not dry:
# Create the folder if it doesn't exist, with parents as needed
working_directory.mkdir(parents=True, exist_ok=True)
logging_directory.mkdir(parents=True, exist_ok=True)

logger.info(
"Succesfully initialized tessif's working directory at %s",
working_directory,
)
logger.info(
"Succesfully initialized tessif's working directory at %s",
working_directory,
)

return sys.exit(os.EX_OK)

Expand Down Expand Up @@ -103,7 +102,7 @@ def integrate(plugin, venv_dir=None, dry=False):
logger.info("Initializing new python binary at %s", python_bin)

if not dry:
venv.create(venv_dir, upgrade_deps=True, with_pip=True)
venv.create(venv_dir, with_pip=True)

logger.info(
"Succesfully created venv for plugin %s at %s",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tropp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_basic_es_tropping(system_model_name):
@pytest.mark.parametrize("system_model_name", scientific_creates)
def test_scientific_es_tropping(system_model_name):
"""Test tropping using the scientific tessif-example sysmods."""
tsf_sys_mod = getattr(basic, system_model_name)()
tsf_sys_mod = getattr(scientific, system_model_name)()

results = tsf_sys_mod.tropp(
plugins=PLUGINS,
Expand Down

0 comments on commit d7b5d92

Please sign in to comment.