pyconvexity 0.4.3__tar.gz → 0.4.6.post1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyconvexity might be problematic. Click here for more details.

Files changed (51) hide show
  1. pyconvexity-0.4.6.post1/PKG-INFO +148 -0
  2. pyconvexity-0.4.6.post1/README.md +100 -0
  3. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/pyproject.toml +2 -2
  4. pyconvexity-0.4.6.post1/src/pyconvexity/_version.py +1 -0
  5. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/schema/03_validation_data.sql +2 -1
  6. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/io/netcdf_exporter.py +1 -7
  7. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/io/netcdf_importer.py +82 -113
  8. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/api.py +4 -18
  9. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/batch_loader.py +1 -12
  10. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/builder.py +3 -23
  11. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/solver.py +4 -71
  12. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/storage.py +1 -47
  13. pyconvexity-0.4.6.post1/src/pyconvexity.egg-info/PKG-INFO +148 -0
  14. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity.egg-info/SOURCES.txt +1 -0
  15. pyconvexity-0.4.3/PKG-INFO +0 -47
  16. pyconvexity-0.4.3/src/pyconvexity/_version.py +0 -1
  17. pyconvexity-0.4.3/src/pyconvexity.egg-info/PKG-INFO +0 -47
  18. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/setup.cfg +0 -0
  19. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/__init__.py +0 -0
  20. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/core/__init__.py +0 -0
  21. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/core/database.py +0 -0
  22. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/core/errors.py +0 -0
  23. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/core/types.py +0 -0
  24. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/README.md +0 -0
  25. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/__init__.py +0 -0
  26. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/loaders/__init__.py +0 -0
  27. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/loaders/cache.py +0 -0
  28. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/schema/01_core_schema.sql +0 -0
  29. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/schema/02_data_metadata.sql +0 -0
  30. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/sources/__init__.py +0 -0
  31. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/data/sources/gem.py +0 -0
  32. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/io/__init__.py +0 -0
  33. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/io/excel_exporter.py +0 -0
  34. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/io/excel_importer.py +0 -0
  35. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/__init__.py +0 -0
  36. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/attributes.py +0 -0
  37. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/carriers.py +0 -0
  38. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/components.py +0 -0
  39. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/network.py +0 -0
  40. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/results.py +0 -0
  41. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/models/scenarios.py +0 -0
  42. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/__init__.py +0 -0
  43. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/__init__.py +0 -0
  44. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/solvers/pypsa/constraints.py +0 -0
  45. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/timeseries.py +0 -0
  46. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/validation/__init__.py +0 -0
  47. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity/validation/rules.py +0 -0
  48. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity.egg-info/dependency_links.txt +0 -0
  49. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity.egg-info/requires.txt +0 -0
  50. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/src/pyconvexity.egg-info/top_level.txt +0 -0
  51. {pyconvexity-0.4.3 → pyconvexity-0.4.6.post1}/tests/test_core_types.py +0 -0
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyconvexity
3
+ Version: 0.4.6.post1
4
+ Summary: Python library for energy system modeling and optimization with PyPSA
5
+ Author-email: Convexity Team <info@convexity.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bayesian-energy/pyconvexity
8
+ Project-URL: Repository, https://github.com/bayesian-energy/pyconvexity
9
+ Project-URL: Issues, https://github.com/bayesian-energy/pyconvexity/issues
10
+ Project-URL: Documentation, https://pyconvexity.readthedocs.io
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: pandas>=1.5.0
23
+ Requires-Dist: numpy>=1.21.0
24
+ Requires-Dist: pyarrow>=10.0.0
25
+ Provides-Extra: pypsa
26
+ Requires-Dist: pypsa>=0.25.0; extra == "pypsa"
27
+ Requires-Dist: networkx; extra == "pypsa"
28
+ Requires-Dist: scipy; extra == "pypsa"
29
+ Requires-Dist: xarray; extra == "pypsa"
30
+ Provides-Extra: excel
31
+ Requires-Dist: openpyxl>=3.0.0; extra == "excel"
32
+ Requires-Dist: xlsxwriter>=3.0.0; extra == "excel"
33
+ Provides-Extra: netcdf
34
+ Requires-Dist: netcdf4>=1.6.0; extra == "netcdf"
35
+ Requires-Dist: xarray>=2022.3.0; extra == "netcdf"
36
+ Provides-Extra: data
37
+ Requires-Dist: country-converter>=1.0.0; extra == "data"
38
+ Requires-Dist: pyyaml>=6.0.0; extra == "data"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
41
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
42
+ Requires-Dist: black>=22.0.0; extra == "dev"
43
+ Requires-Dist: isort>=5.10.0; extra == "dev"
44
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
45
+ Requires-Dist: pre-commit>=2.20.0; extra == "dev"
46
+ Provides-Extra: all
47
+ Requires-Dist: pyconvexity[data,excel,netcdf,pypsa]; extra == "all"
48
+
49
+ # pyconvexity
50
+
51
+ Python library for energy system modeling and optimization with PyPSA.
52
+
53
+ [![PyPI version](https://badge.fury.io/py/pyconvexity.svg)](https://badge.fury.io/py/pyconvexity)
54
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
56
+
57
+ ## Overview
58
+
59
+ pyconvexity is the Python library that powers [Convexity](https://bayesian.energy/convexity), providing programmatic access to energy system modeling and optimization. It stores models in SQLite databases and integrates with PyPSA for solving.
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install pyconvexity
65
+ ```
66
+
67
+ With optional dependencies:
68
+
69
+ ```bash
70
+ pip install pyconvexity[pypsa] # PyPSA solver integration
71
+ pip install pyconvexity[excel] # Excel import/export
72
+ pip install pyconvexity[all] # All optional dependencies
73
+ ```
74
+
75
+ ## Quick Start
76
+
77
+ ```python
78
+ import pyconvexity as px
79
+
80
+ # Create a new model database
81
+ px.create_database_with_schema("my_model.db")
82
+
83
+ # Create a network
84
+ with px.database_context("my_model.db") as conn:
85
+ network_req = px.CreateNetworkRequest(
86
+ name="My Network",
87
+ start_time="2024-01-01 00:00:00",
88
+ end_time="2024-01-01 23:00:00",
89
+ time_resolution="PT1H",
90
+ )
91
+ px.create_network(conn, network_req)
92
+
93
+ # Create components
94
+ carrier_id = px.create_carrier(conn, name="AC")
95
+ bus_id = px.create_component(conn, "BUS", "Main Bus", carrier_id=carrier_id)
96
+
97
+ conn.commit()
98
+
99
+ # Solve the network
100
+ result = px.solve_network("my_model.db", solver_name="highs")
101
+ print(f"Success: {result['success']}, Objective: {result['objective_value']}")
102
+ ```
103
+
104
+ ## Documentation
105
+
106
+ Full documentation is available at: **[docs.bayesian.energy](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/)**
107
+
108
+ - [API Reference](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/api/api-reference)
109
+ - [Examples & Tutorials](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/examples/example-1/)
110
+
111
+ ## Development
112
+
113
+ ### Setup
114
+
115
+ ```bash
116
+ git clone https://github.com/bayesian-energy/pyconvexity.git
117
+ cd pyconvexity
118
+ pip install -e ".[dev,all]"
119
+ ```
120
+
121
+ ### Running Tests
122
+
123
+ ```bash
124
+ pytest
125
+ ```
126
+
127
+ ### Documentation Deployment
128
+
129
+ API documentation is auto-generated and synced to [bayesian-docs](https://github.com/bayesian-energy/bayesian-docs).
130
+
131
+ **Generate API docs locally:**
132
+
133
+ ```bash
134
+ python scripts/generate_api_docs.py --output-dir api-docs
135
+ ```
136
+
137
+ **How it works:**
138
+ 1. On push to `main` or release, the `sync-docs.yml` workflow runs
139
+ 2. It generates API markdown from Python docstrings
140
+ 3. Commits the generated docs to the `bayesian-docs` repository
141
+
142
+ **Setup for maintainers:**
143
+ - Add `DOCS_DEPLOY_TOKEN` secret to the repo (personal access token with `repo` scope for bayesian-docs)
144
+
145
+ ## License
146
+
147
+ MIT License - see [LICENSE](LICENSE) for details.
148
+
@@ -0,0 +1,100 @@
1
+ # pyconvexity
2
+
3
+ Python library for energy system modeling and optimization with PyPSA.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/pyconvexity.svg)](https://badge.fury.io/py/pyconvexity)
6
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Overview
10
+
11
+ pyconvexity is the Python library that powers [Convexity](https://bayesian.energy/convexity), providing programmatic access to energy system modeling and optimization. It stores models in SQLite databases and integrates with PyPSA for solving.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install pyconvexity
17
+ ```
18
+
19
+ With optional dependencies:
20
+
21
+ ```bash
22
+ pip install pyconvexity[pypsa] # PyPSA solver integration
23
+ pip install pyconvexity[excel] # Excel import/export
24
+ pip install pyconvexity[all] # All optional dependencies
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```python
30
+ import pyconvexity as px
31
+
32
+ # Create a new model database
33
+ px.create_database_with_schema("my_model.db")
34
+
35
+ # Create a network
36
+ with px.database_context("my_model.db") as conn:
37
+ network_req = px.CreateNetworkRequest(
38
+ name="My Network",
39
+ start_time="2024-01-01 00:00:00",
40
+ end_time="2024-01-01 23:00:00",
41
+ time_resolution="PT1H",
42
+ )
43
+ px.create_network(conn, network_req)
44
+
45
+ # Create components
46
+ carrier_id = px.create_carrier(conn, name="AC")
47
+ bus_id = px.create_component(conn, "BUS", "Main Bus", carrier_id=carrier_id)
48
+
49
+ conn.commit()
50
+
51
+ # Solve the network
52
+ result = px.solve_network("my_model.db", solver_name="highs")
53
+ print(f"Success: {result['success']}, Objective: {result['objective_value']}")
54
+ ```
55
+
56
+ ## Documentation
57
+
58
+ Full documentation is available at: **[docs.bayesian.energy](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/)**
59
+
60
+ - [API Reference](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/api/api-reference)
61
+ - [Examples & Tutorials](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/examples/example-1/)
62
+
63
+ ## Development
64
+
65
+ ### Setup
66
+
67
+ ```bash
68
+ git clone https://github.com/bayesian-energy/pyconvexity.git
69
+ cd pyconvexity
70
+ pip install -e ".[dev,all]"
71
+ ```
72
+
73
+ ### Running Tests
74
+
75
+ ```bash
76
+ pytest
77
+ ```
78
+
79
+ ### Documentation Deployment
80
+
81
+ API documentation is auto-generated and synced to [bayesian-docs](https://github.com/bayesian-energy/bayesian-docs).
82
+
83
+ **Generate API docs locally:**
84
+
85
+ ```bash
86
+ python scripts/generate_api_docs.py --output-dir api-docs
87
+ ```
88
+
89
+ **How it works:**
90
+ 1. On push to `main` or release, the `sync-docs.yml` workflow runs
91
+ 2. It generates API markdown from Python docstrings
92
+ 3. Commits the generated docs to the `bayesian-docs` repository
93
+
94
+ **Setup for maintainers:**
95
+ - Add `DOCS_DEPLOY_TOKEN` secret to the repo (personal access token with `repo` scope for bayesian-docs)
96
+
97
+ ## License
98
+
99
+ MIT License - see [LICENSE](LICENSE) for details.
100
+
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyconvexity"
7
- version = "0.4.3"
7
+ version = "0.4.6.post1"
8
8
  description = "Python library for energy system modeling and optimization with PyPSA"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -81,7 +81,7 @@ profile = "black"
81
81
  line_length = 88
82
82
 
83
83
  [tool.mypy]
84
- python_version = "0.4.3"
84
+ python_version = "0.4.6.post1"
85
85
  warn_return_any = true
86
86
  warn_unused_configs = true
87
87
  disallow_untyped_defs = true
@@ -0,0 +1 @@
1
+ __version__ = "0.4.6.post1"
@@ -33,7 +33,8 @@ INSERT INTO attribute_validation_rules (component_type, attribute_name, display_
33
33
  ('BUS', 'q', 'Reactive Power', 'float', 'MVar', '0', 'timeseries', FALSE, FALSE, 'reactive power (positive if net generation at bus)', NULL, NULL, 'electrical', TRUE),
34
34
  ('BUS', 'v_mag_pu', 'Voltage Magnitude', 'float', 'per unit', '1', 'timeseries', FALSE, FALSE, 'Voltage magnitude, per unit of v_nom', NULL, NULL, 'electrical', TRUE),
35
35
  ('BUS', 'v_ang', 'Voltage Angle', 'float', 'radians', '0', 'timeseries', FALSE, FALSE, 'Voltage angle', NULL, NULL, 'electrical', TRUE),
36
- ('BUS', 'marginal_price', 'Marginal Price', 'float', 'currency/MWh', '0', 'timeseries', FALSE, FALSE, 'Locational marginal price from LOPF from power balance constraint', NULL, NULL, 'costs', TRUE);
36
+ ('BUS', 'marginal_price', 'Marginal Price', 'float', 'currency/MWh', '0', 'timeseries', FALSE, FALSE, 'Locational marginal price from LOPF from power balance constraint', NULL, NULL, 'costs', TRUE),
37
+ ('BUS', 'market_price', 'Market Price', 'float', 'currency/MWh', '0', 'timeseries', FALSE, FALSE, 'Custom calculated market price for the bus (independent of PyPSA marginal cost)', NULL, NULL, 'costs', TRUE);
37
38
 
38
39
  -- ============================================================================
39
40
  -- GENERATOR ATTRIBUTES
@@ -3,22 +3,18 @@ NetCDF exporter for PyConvexity energy system models.
3
3
  Exports networks to PyPSA NetCDF format using existing PyPSA infrastructure.
4
4
  """
5
5
 
6
- import logging
7
6
  from typing import Dict, Any, Optional, Callable
8
7
  from pathlib import Path
9
8
 
10
9
  # Import existing PyPSA functionality from pyconvexity
11
- from pyconvexity.core.database import open_connection
12
10
  from pyconvexity.solvers.pypsa import build_pypsa_network
13
11
 
14
- logger = logging.getLogger(__name__)
15
-
16
12
 
17
13
  class NetCDFModelExporter:
18
14
  """Export network model to PyPSA NetCDF format"""
19
15
 
20
16
  def __init__(self):
21
- self.logger = logging.getLogger(__name__)
17
+ pass
22
18
 
23
19
  def export_to_netcdf(
24
20
  self,
@@ -78,7 +74,6 @@ class NetCDFModelExporter:
78
74
  }
79
75
 
80
76
  except Exception as e:
81
- self.logger.error(f"NetCDF export failed: {e}", exc_info=True)
82
77
  if progress_callback:
83
78
  progress_callback(None, f"Export failed: {str(e)}")
84
79
  raise
@@ -141,7 +136,6 @@ class NetCDFModelExporter:
141
136
  }
142
137
 
143
138
  except Exception as e:
144
- self.logger.error(f"CSV export failed: {e}", exc_info=True)
145
139
  if progress_callback:
146
140
  progress_callback(None, f"Export failed: {str(e)}")
147
141
  raise