diff --git a/tutorials/03-advanced/03-project-file/README.md b/tutorials/03-advanced/03-project-file/README.md new file mode 100644 index 00000000..6d3c404e --- /dev/null +++ b/tutorials/03-advanced/03-project-file/README.md @@ -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 +``` diff --git a/tutorials/03-advanced/03-project-file/data/inventory.csv b/tutorials/03-advanced/03-project-file/data/inventory.csv new file mode 100644 index 00000000..f51b387c --- /dev/null +++ b/tutorials/03-advanced/03-project-file/data/inventory.csv @@ -0,0 +1,5 @@ +id,weight +s01,1 +s02,2 +s03,3 +s04,4 diff --git a/tutorials/03-advanced/03-project-file/lcaac-mock.yaml b/tutorials/03-advanced/03-project-file/lcaac-mock.yaml new file mode 100644 index 00000000..23a094a1 --- /dev/null +++ b/tutorials/03-advanced/03-project-file/lcaac-mock.yaml @@ -0,0 +1,6 @@ +name: Project file +description: Sample project to illustrate the use of lcaac.yaml +connectors: + - name: csv + options: + directory: mock diff --git a/tutorials/03-advanced/03-project-file/lcaac.yaml b/tutorials/03-advanced/03-project-file/lcaac.yaml new file mode 100644 index 00000000..029fd63f --- /dev/null +++ b/tutorials/03-advanced/03-project-file/lcaac.yaml @@ -0,0 +1,6 @@ +name: Project file +description: Sample project to illustrate the use of lcaac.yaml +connectors: + - name: csv + options: + directory: data diff --git a/tutorials/03-advanced/03-project-file/main.lca b/tutorials/03-advanced/03-project-file/main.lca new file mode 100644 index 00000000..91e269fa --- /dev/null +++ b/tutorials/03-advanced/03-project-file/main.lca @@ -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 + } +} diff --git a/tutorials/03-advanced/03-project-file/mock/inventory.csv b/tutorials/03-advanced/03-project-file/mock/inventory.csv new file mode 100644 index 00000000..9a518d20 --- /dev/null +++ b/tutorials/03-advanced/03-project-file/mock/inventory.csv @@ -0,0 +1,5 @@ +id,weight +s01,10 +s02,20 +s03,30 +s04,40