diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4fc439..1b637cd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -141,7 +141,7 @@ jobs: - uses: conda-incubator/setup-miniconda@v2 with: python-version: ${{ matrix.python-version }} - channels: conda-forge + channels: conda-forge,cmutel,konstantinstadler,haasad,pascallesage,romainsacchi allow-softlinks: true channel-priority: strict auto-update-conda: true diff --git a/conda/meta.yaml b/conda/meta.yaml index 7ed56c6..2fbb0e3 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -26,7 +26,7 @@ requirements: - premise - pyyaml - bw_processing - - bw2calc=2.0.DEV16 + - bw2calc - datapackage - pyprind - platformdirs diff --git a/example/example.ipynb b/example/example.ipynb index 3fada37..715943e 100644 --- a/example/example.ipynb +++ b/example/example.ipynb @@ -645,25 +645,45 @@ "Log file: /Users/romain/Library/Logs/pathways/pathways.log\n", "Calculating LCA results for some model...\n", "--- Calculating LCA results for Scenario A...\n", + "------ Calculating LCA results for 2020...\n", + "Warning: No valid output stream.\n", + "------ Calculating LCA results for 2030...\n", + "Warning: No valid output stream.\n", + "------ Calculating LCA results for 2040...\n", + "Warning: No valid output stream.\n", + "------ Calculating LCA results for 2050...\n", + "Warning: No valid output stream.\n", + "--- Calculating LCA results for Scenario B...\n", + "------ Calculating LCA results for 2020...\n", + "Warning: No valid output stream.\n", + "------ Calculating LCA results for 2030...\n", + "Warning: No valid output stream.\n", + "------ Calculating LCA results for 2050...\n", + "Warning: No valid output stream.\n", "------ Calculating LCA results for 2040...\n", - "------ Calculating LCA results for 2050...\n" + "Warning: No valid output stream.\n" ] }, { - "ename": "ValueError", - "evalue": "Sheet 'Double accounting - Zeroed' already exists and if_sheet_exists is set to 'error'.", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRemoteTraceback\u001b[0m Traceback (most recent call last)", - "\u001b[0;31mRemoteTraceback\u001b[0m: \n\"\"\"\nTraceback (most recent call last):\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/multiprocessing/pool.py\", line 125, in worker\n result = (True, func(*args, **kwds))\n ^^^^^^^^^^^^^^^^^^^\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/multiprocessing/pool.py\", line 48, in mapstar\n return list(map(*args))\n ^^^^^^^^^^^^^^^^\n File \"/Users/romain/GitHub/pathways/pathways/lca.py\", line 444, in _calculate_year\n log_double_accounting(\n File \"/Users/romain/GitHub/pathways/pathways/stats.py\", line 66, in log_double_accounting\n filtered_df.to_excel(\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/site-packages/pandas/util/_decorators.py\", line 333, in wrapper\n return func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/site-packages/pandas/core/generic.py\", line 2414, in to_excel\n formatter.write(\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/site-packages/pandas/io/formats/excel.py\", line 952, in write\n writer._write_cells(\n File \"/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/site-packages/pandas/io/excel/_openpyxl.py\", line 463, in _write_cells\n raise ValueError(\nValueError: Sheet 'Double accounting - Zeroed' already exists and if_sheet_exists is set to 'error'.\n\"\"\"", - "\nThe above exception was the direct cause of the following exception:\n", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[1], line 8\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m 3\u001b[0m p \u001b[38;5;241m=\u001b[39m Pathways(\n\u001b[1;32m 4\u001b[0m datapackage\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdatapackage_sample/datapackage.json\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 5\u001b[0m debug\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m 6\u001b[0m )\n\u001b[0;32m----> 8\u001b[0m \u001b[43mp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcalculate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethods\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mEF v3.1 EN15804 - climate change - global warming potential (GWP100)\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43mregions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mEU\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43mscenarios\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 12\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mScenario A\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mScenario B\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 14\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 15\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 16\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtechnology A\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 17\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 18\u001b[0m \u001b[43m \u001b[49m\u001b[43myears\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\n\u001b[1;32m 19\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2020\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 20\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2030\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 21\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2040\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 22\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m2050\u001b[39;49m\n\u001b[1;32m 23\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 24\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_distributions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m500\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 25\u001b[0m \u001b[43m \u001b[49m\u001b[43mmultiprocessing\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 26\u001b[0m \u001b[43m \u001b[49m\u001b[43mdouble_accounting\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mEnergy\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 27\u001b[0m \u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/GitHub/pathways/pathways/pathways.py:400\u001b[0m, in \u001b[0;36mPathways.calculate\u001b[0;34m(self, methods, double_accounting, models, scenarios, regions, years, variables, multiprocessing, demand_cutoff, use_distributions, subshares)\u001b[0m\n\u001b[1;32m 393\u001b[0m \u001b[38;5;66;03m# Process each region in parallel\u001b[39;00m\n\u001b[1;32m 394\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Pool(cpu_count()) \u001b[38;5;28;01mas\u001b[39;00m p:\n\u001b[1;32m 395\u001b[0m \u001b[38;5;66;03m# store th results as a dictionary with years as keys\u001b[39;00m\n\u001b[1;32m 396\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 397\u001b[0m {\n\u001b[1;32m 398\u001b[0m (model, scenario, year): result\n\u001b[1;32m 399\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m year, result \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(\n\u001b[0;32m--> 400\u001b[0m years, \u001b[43mp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmap\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_calculate_year\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 401\u001b[0m )\n\u001b[1;32m 402\u001b[0m }\n\u001b[1;32m 403\u001b[0m )\n\u001b[1;32m 404\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 405\u001b[0m results\u001b[38;5;241m.\u001b[39mupdate(\n\u001b[1;32m 406\u001b[0m {\n\u001b[1;32m 407\u001b[0m (model, scenario, year): _calculate_year(\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 431\u001b[0m }\n\u001b[1;32m 432\u001b[0m )\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/multiprocessing/pool.py:367\u001b[0m, in \u001b[0;36mPool.map\u001b[0;34m(self, func, iterable, chunksize)\u001b[0m\n\u001b[1;32m 362\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mmap\u001b[39m(\u001b[38;5;28mself\u001b[39m, func, iterable, chunksize\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 363\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m'''\u001b[39;00m\n\u001b[1;32m 364\u001b[0m \u001b[38;5;124;03m Apply `func` to each element in `iterable`, collecting the results\u001b[39;00m\n\u001b[1;32m 365\u001b[0m \u001b[38;5;124;03m in a list that is returned.\u001b[39;00m\n\u001b[1;32m 366\u001b[0m \u001b[38;5;124;03m '''\u001b[39;00m\n\u001b[0;32m--> 367\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_map_async\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43miterable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmapstar\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchunksize\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/opt/homebrew/Caskroom/miniforge/base/envs/pathways/lib/python3.11/multiprocessing/pool.py:774\u001b[0m, in \u001b[0;36mApplyResult.get\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 772\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_value\n\u001b[1;32m 773\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 774\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_value\n", - "\u001b[0;31mValueError\u001b[0m: Sheet 'Double accounting - Zeroed' already exists and if_sheet_exists is set to 'error'." + "name": "stderr", + "output_type": "stream", + "text": [ + "0% [########] 100% | ETA: 00:00:00" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Statistical analysis files: /Users/romain/Library/Application Support/pathways/stats\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "Total time elapsed: 00:00:00\n" ] } ],