Skip to content

Commit

Permalink
tutorials: added tutorial for project configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
Peva Blanchard committed Jun 3, 2024
1 parent 8dee67b commit 3ce9a5e
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tutorials/03-advanced/03-project-file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Project description file

A LCA as Code project can be specified with a YAML configuration.
In this tutorial, the configuration file is used to specify:
- the project name
- the project description
- and customizing the CSV connector

Hence, the file `lcaac.yaml` contains
```yaml
name: Project file
description: Sample project to illustrate the use of lcaac.yaml
connectors:
- name: csv
options:
directory: data
```
while the file `lcaac-mock.yaml` contains
```yaml
name: Project file
description: Sample project to illustrate the use of lcaac.yaml
connectors:
- name: csv
options:
directory: mock
```

Here each file specifies a different location for the folder containing the CSV files supporting the datasources.
You can choose which settings to use with the cli option `-p` or `--project`.
```bash
lcaac assess --project lcaac.yaml main
lcaac assess --project lcaac-mock.yaml main
```
5 changes: 5 additions & 0 deletions tutorials/03-advanced/03-project-file/data/inventory.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,weight
s01,1
s02,2
s03,3
s04,4
6 changes: 6 additions & 0 deletions tutorials/03-advanced/03-project-file/lcaac-mock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Project file
description: Sample project to illustrate the use of lcaac.yaml
connectors:
- name: csv
options:
directory: mock
6 changes: 6 additions & 0 deletions tutorials/03-advanced/03-project-file/lcaac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Project file
description: Sample project to illustrate the use of lcaac.yaml
connectors:
- name: csv
options:
directory: data
36 changes: 36 additions & 0 deletions tutorials/03-advanced/03-project-file/main.lca
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
datasource inventory {
location = "inventory.csv"
schema {
id = "s01"
weight = 0 kg
}
}

process main {
products {
1 kg main
}
impacts {
for_each item from inventory {
item.weight mass
}
}
}

test main_with_data {
given {
1 kg main from main
}
assert {
mass between 10 kg and 10 kg
}
}

test main_with_mock_data {
given {
1 kg main from main
}
assert {
mass between 100 kg and 100 kg
}
}
5 changes: 5 additions & 0 deletions tutorials/03-advanced/03-project-file/mock/inventory.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,weight
s01,10
s02,20
s03,30
s04,40

0 comments on commit 3ce9a5e

Please sign in to comment.