EOS-AYCE

Eaternity's software platform serving as an open-source environmental operating system (EOS) for all you can eat (AYCE) for climate.
https://gitlab.com/eaternity/eos

Category: Industrial Ecology
Sub Category: Life Cycle Assessment

Last synced: about 1 hour ago
JSON representation

Repository metadata

Environmental operating system

https://gitlab.com/eaternity/eos/blob/develop/

          
# Eaternity EOS

This project embodies Eaternity's mission of "Accelerating the World's Transition to a Sustainable Food System" by establishing the necessary infrastructure to calculate and publish the major environmental impacts of all foods. We have named this initiative "All You Can Eat" or AYCE, which represents a software platform serving as an open-source environmental operating system (EOS) to achieve our goals. The projects website is developed here: [http://ayce.earth](http://ayce.earth).

Our goal is to provide an accurate, affordable, and constructive environmental operating system for decision-making and communication across major food-providing business segments (producers, restaurants, and retailers)⁠. This includes:
- To make environmental information about food accessible to users in the restaurant and food industry⁠ through our existing API
- To calculate the complete life cycle of food products from cradle to kitchen gate, including aspects like packaging, disposal, processing, storage, and distribution⁠
- To automate calculations and reduce human labor costs, with the aim of achieving high quality calculations at a cost of just a few Euros per calculation⁠
- To serve as the backbone for the "All You Can Eat" (AYCE) project, making food environmental impacts free and accessible to everyone⁠
⁠​

Overall, EOS is central to Eaternity's mission by providing comprehensive, efficient, and accessible environmental impact data for food products.

#### Our strategy revolves around leveraging our core strengths, which include:

- Expertise in life cycle assessment, enabling us to consistently perform comprehensive and accurate impact calculations for individual food products.
- Proficiency in building software architectures, as demonstrated by our successful development of our CO2 calculation tool for numerous restaurants. Over the past decade, we have accumulated invaluable knowledge and experience in this field.
- Utilization of recurring revenue streams to finance this operation. Having established a break-even business model, we have the freedom to allocate our resources towards research and development in the years ahead.

#### To ensure the effectiveness of our platform, we place significant emphasis on data and software architecture, specifically focusing on:

- Computational efficiency, allowing for scalable, dynamic, and instantaneous impact recalculations through the utilization of matrix calculus and cloud architecture.
- Rapid development capabilities, achieved by providing a structured framework and generic components that facilitate the addition of complexity without unnecessarily complicating the system. One approach involves implementing independent gap-filling modules that can be executed and scheduled separately, relying on a glossary for dependencies rather than direct data connections.
- Transparency and accessibility, enabling non-IT individuals to easily review the calculation process. This is achieved by ensuring transparent, deterministic graph mutations that can be comprehended by a wider audience.

We document our progress and decisions on Notion, which you can find here: [http://eaternity.notion.site](https://www.notion.so/eaternity/Project-EOS-AYCE-kale-a8f5d9809b65416aa159adf83f0f459b) (not yet public).

**We actively seek collaborations with scientists and food retailers to enhance our models and share our results with the public. Please feel free to reach out to us if you are interested in collaborating.**

## Project Setup

You need to have docker installed on your system (preferably in rootless mode).

First, create a folder `secrets` in the root directory of the project and add the `service_account.json` file for the
Google Cloud service account.

Then copy the `.env.sample` file to `.env` and adjust the environment variables to your needs:

```bash
cp .env.sample .env
```

also make sure to create a temp folder for the data:

```bash
mkdir -p temp_data/location_gfm
```

There are two options how you can run EOS:

## Option 1: Python on host system

This option is most suitable for development, because it allows you to easily attach debugging tools while you develop gap-filling-modules.

If you want to contribute to the project by developing gap-filling modules,
we suggest to install PyCharm Community Edition or Visual Studio Code with the following extensions:

* Python
* PyLance
* PythonDebugger
* Black Formatter
* isort
* Ruff

Go through [CONTRIBUTING.md](CONTRIBUTING.md) for configuration.

### Requirements:

Please make sure to first install:

- docker >= 24.0.4
- uv (install with: `curl -LsSf https://astral.sh/uv/install.sh | sh`)

### Linux x86_64

Install uv and sync dependencies. uv will automatically download the correct Python version (3.11.3) if not already installed:

```bash
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install Python 3.11.3 and all dependencies
uv sync --all-packages
```

This will:
1. Download Python 3.11.3 if needed (based on `requires-python` in pyproject.toml)
2. Create a `.venv` virtual environment in the project root
3. Install all workspace packages and dependencies from `uv.lock`

### macOS aarch64 (Apple Silicon)

On x86_64, we use `pypardiso` sparse solver that depends on Intel MKL. On aarch64 (Apple Silicon), we use `scikit-umfpack` as a fallback.

Additional system dependencies are required for building native extensions:

```bash
# Install system dependencies via Homebrew
brew install suite-sparse swig c-blosc hdf5 lzo

# Set environment variables for building tables
export HDF5_DIR=/opt/homebrew/opt/hdf5
export BLOSC_DIR=/opt/homebrew/opt/c-blosc
export LZO_DIR=/opt/homebrew/opt/lzo

# Install Python and all dependencies
uv sync --all-packages
```

### All platforms

Copy the provided sample env file and start the database service and seed the database with our schema:

```bash
docker compose up -d postgres rabbitmq gadm_cache
uv run python -m database --reinit
uv run python -m inventory_importer.bw_import_controller --edb_path ./temp_data/brightway --download_from_gdrive 1QGgJPHuz-m7MA5zIkerN1b2EsId8dnIu --import_using_airtable --import_fao_statistics  --import_all_impact_assessments --import_glossary --import_matchings_from_airtable --gfm_import_data
```

Now you can run the python services on the host system:

```bash
uv run python -m api
uv run python -m legacy_api
```

To restore local transport (EcoTransit) caches, start workflows / dagit locally and run transport_cache_restore_job on your local database.

At this point, the database will be seeded but will have no recipe data. You can optionally generate
some test recipes with this script:

```bash
uv run python -m scripts.generate_recipes --api-key KEY --base-url http://localhost:8050
```

Refer to its `--help` for more info, you can find the KEY for our test namespace in https://gitlab.com/eaternity-cluster/bruno under Auth tab of e.g. the get_kitchens endpoint.

PyCharm debug/run configurations for above python services are stored in `.idea/runConfigurations/` and can
easily be used to reset the database to a clean state and to start the api services in the PyCharm Debugger.

If you use VS Code, ask a workmate for corresponding launch configurations and store them as `.vscode/launch.json`

For these debug configurations to work, you should select the python interpreter of the virtual environment created by uv. By default, uv creates the environment at:

    .venv/bin/python

If using PyCharm, select the interpreter in project settings.

If using VS Code, open the Command Palette (`Ctrl+Shift+P`) and search for `Python: Select Interpreter` to choose.


## Option 2: Everything in Docker

Alternatively, you can start all services in docker without having python installed on your system:
First build the image and seed the database:

```bash
docker compose build _image_build
docker compose up -d postgres rabbitmq
docker compose --profile initdb run --rm initdb
docker compose --profile inventory_importer run --rm inventory_importer
docker compose --profile inventory_importer_gfm_import_data run --rm inventory_importer_gfm_import_data
```

Now you can start the dockerized python services:

```bash
docker compose --profile api up -d
```

## What to try out

After you followed option 1 or 2 above, you should be able to access the swagger ui and do example requests:

- new API at [http://localhost:8040/docs](http://localhost:8040/v2/docs)
- legacy API at [http://localhost:8050/docs](http://localhost:8050/api/docs)

Please, also checkout the example requests in the `/scripts` folder to get started.

## Troubleshooting

We use multiprocessing in unittests of the `legacy_api` package to run the new api service in a separate process.
In order to be able to debug the multiprocessing code with PyCharm, you need to enable in the PyCharm settings
under `Python Debugger` the option `Gevent compatible`.

When adding a new dependency to sub-packages (for example, `core` or `api`), update the pyproject.toml in that package
and run `uv lock` then `uv sync --all-packages` from the root folder.

## To check for updates of dependencies:

To show currently installed versions and check for updates:

```bash
uv tree  # show dependency tree
uv lock --upgrade  # upgrade all dependencies to latest compatible versions
```

        

Committers metadata

Last synced: about 5 hours ago

Total Commits: 1,666
Total Committers: 19
Avg Commits per committer: 87.684
Development Distribution Score (DDS): 0.72

Commits in past year: 699
Committers in past year: 11
Avg Commits per committer in past year: 63.545
Development Distribution Score (DDS) in past year: 0.67

Name Email Commits
Holger Finger h****r@p****m 467
Yannick Schubert y****t@e****h 399
Holger Finger h****r@g****m 239
schoi839 s****i@e****h 197
Simon Greuter 6****s@u****m 99
Alexei Glon a****n@e****h 74
Simon Greuter s****r@e****h 65
Renaud Richardet r****t@e****h 38
Michael Kefeder m****r@e****h 21
Alexandr Nigay a****y@e****h 20
Michael Kefeder m****r@g****m 15
Manuel Klarmann m****n@e****h 10
Jens Hinkelmann j****s@h****h 8
Vitor Bosshard v****d@e****h 5
Philip Winkler p****1@d****k 3
Jens Hinkelmann j****n@e****h 2
Patrick Haldi p****i@m****g 2
Hrishikesh Nangare h****e@a****m 1
Renaud Richardet r****t@i****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 2 days ago


Dependencies

eos-ui/package-lock.json npm
  • 125 dependencies
eos-ui/package.json npm
  • @vitejs/plugin-vue ^3.1.0 development
  • vite ^3.1.0 development
  • vite-plugin-vuetify ^1.0.0-alpha.12 development
  • vue-cli-plugin-vuetify ~2.5.5 development
  • @braks/vue-flow ^0.4.38
  • @mdi/font 5.9.55
  • roboto-fontface *
  • vue ^3.2.37
  • vue-router ^4.1.5
  • vuejs-tree ^3.0.2
  • vuetify ^3.0.0-beta.0
  • webfontloader ^1.0.0
api/poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • debugpy 1.6.2 develop
  • iniconfig 1.1.1 develop
  • packaging 21.3 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • tomli 2.0.1 develop
  • anyio 3.6.1
  • asgiref 3.5.2
  • asyncpg 0.26.0
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • click 8.1.3
  • colorama 0.4.5
  • core 0.1.0
  • database 0.1.0
  • fastapi 0.70.1
  • h11 0.13.0
  • httptools 0.2.0
  • idna 3.3
  • numpy 1.21.3
  • protobuf 3.20.1
  • pydantic 1.9.1
  • python-dotenv 0.20.0
  • pyyaml 6.0
  • requests 2.28.1
  • sniffio 1.2.0
  • starlette 0.16.0
  • structlog 21.5.0
  • typing-extensions 4.3.0
  • urllib3 1.26.11
  • uvicorn 0.15.0
  • uvloop 0.16.0
  • watchgod 0.8.2
  • websockets 10.3
api/pyproject.toml pypi
  • debugpy ^1.6.0 develop
  • pytest ^7.1.2 develop
  • core *
  • database *
  • fastapi ^0.70.0
  • python ~3.10.1
  • structlog ^21.5.0
  • uvicorn ^0.15.0
core/poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • colorama 0.4.5 develop
  • debugpy 1.6.2 develop
  • iniconfig 1.1.1 develop
  • packaging 21.3 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • tomli 2.0.1 develop
  • asyncpg 0.26.0
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • database 0.1.0
  • idna 3.3
  • numpy 1.21.3
  • protobuf 3.20.1
  • requests 2.28.1
  • urllib3 1.26.11
core/pyproject.toml pypi
  • debugpy ^1.6.0 develop
  • pytest ^7.1.2 develop
  • database *
  • numpy 1.21.3
  • python ~3.10.1
database/poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • colorama 0.4.5 develop
  • debugpy 1.6.2 develop
  • iniconfig 1.1.1 develop
  • packaging 21.3 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • tomli 2.0.1 develop
  • asyncpg 0.26.0
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • idna 3.3
  • protobuf 3.20.1
  • requests 2.28.1
  • urllib3 1.26.11
database/pyproject.toml pypi
  • debugpy ^1.6.0 develop
  • pytest ^7.1.2 develop
  • asyncpg ^0.26.0
  • protobuf 3.20.*
  • python ~3.10.1
  • requests ^2.28.1
legacy_api/poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • debugpy 1.6.2 develop
  • iniconfig 1.1.1 develop
  • packaging 21.3 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • tomli 2.0.1 develop
  • anyio 3.6.1
  • asgiref 3.5.2
  • asyncpg 0.26.0
  • certifi 2022.6.15
  • charset-normalizer 2.1.0
  • click 8.1.3
  • colorama 0.4.5
  • core 0.1.0
  • database 0.1.0
  • fastapi 0.70.1
  • h11 0.13.0
  • httptools 0.2.0
  • idna 3.3
  • numpy 1.21.3
  • protobuf 3.20.1
  • pydantic 1.9.1
  • python-dotenv 0.20.0
  • pyyaml 6.0
  • requests 2.28.1
  • sniffio 1.2.0
  • starlette 0.16.0
  • structlog 21.5.0
  • typing-extensions 4.3.0
  • urllib3 1.26.11
  • uvicorn 0.15.0
  • uvloop 0.16.0
  • watchgod 0.8.2
  • websockets 10.3
legacy_api/pyproject.toml pypi
  • debugpy ^1.6.0 develop
  • pytest ^7.1.2 develop
  • core *
  • database *
  • fastapi ^0.70.0
  • python ~3.10.1
  • structlog ^21.5.0
  • uvicorn ^0.15.0
poetry.lock pypi
  • atomicwrites 1.4.1 develop
  • autopep8 1.7.0 develop
  • debugpy 1.6.3 develop
  • httpcore 0.15.0 develop
  • httpx 0.23.0 develop
  • iniconfig 1.1.1 develop
  • packaging 21.3 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pycodestyle 2.9.1 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • pytest-asyncio 0.19.0 develop
  • rfc3986 1.5.0 develop
  • toml 0.10.2 develop
  • tomli 2.0.1 develop
  • aiohttp 3.8.1
  • aiosignal 1.2.0
  • anyio 3.6.1
  • api 0.1.0
  • asgiref 3.5.2
  • async-timeout 4.0.2
  • asyncpg 0.26.0
  • attrs 22.1.0
  • certifi 2022.6.15
  • charset-normalizer 2.1.1
  • click 8.1.3
  • colorama 0.4.5
  • core 0.1.0
  • database 0.1.0
  • fastapi 0.70.1
  • frozenlist 1.3.1
  • h11 0.12.0
  • httptools 0.2.0
  • idna 3.3
  • legacy-api 0.1.0
  • multidict 6.0.2
  • numpy 1.21.3
  • protobuf 3.20.1
  • pydantic 1.9.2
  • python-dotenv 0.20.0
  • pyyaml 6.0
  • requests 2.28.1
  • sniffio 1.2.0
  • starlette 0.16.0
  • structlog 21.5.0
  • typing-extensions 4.3.0
  • urllib3 1.26.12
  • uvicorn 0.15.0
  • uvloop 0.16.0
  • watchgod 0.8.2
  • websockets 10.3
  • yarl 1.8.1
pyproject.toml pypi
  • aiohttp ^3.8.1 develop
  • asyncpg ^0.26.0 develop
  • autopep8 ^1.6.0 develop
  • debugpy ^1.6.0 develop
  • httpx ^0.23.0 develop
  • pytest ^7.1.2 develop
  • pytest-asyncio ^0.19.0 develop
  • python-dotenv ^0.20.0 develop
  • aiohttp ^3.8.1
  • api *
  • core *
  • database *
  • legacy_api *
  • python ~3.10.1

Score: 5.247024072160486