- Restore Python 3.9 compatibility
- Fixed bug where copying would move over original edges
- Add
create_aggregated_processandcopy_activitiesfunctions - #252: Production edges have stupid labels
- #251: Deleting project should give log message that data is still available
- #250: Serialize
bw_temporalisTemporalDistributionobjects to JSON when saving to database - and restore when loading - #245: Github tests fail on Windows/Python 3.13
- PR #233: Remove `"`` from search to avoid SQL escaping errors
- PR #232: Fix type annotations in Python 3.9
- PR #231: Escape search strings properly for SQLite
FTS5format - PR #230: Fix (some) type annotations
- PR #226: Rebase revisions when necessary
- Fix #227: Setting impact category
num_cfsnot saved to disk - PR #213: Remove parentheses and curly braces from FTS5 search queries
- BREAKING CHANGE: Removed looking up node attributes in reference product edges using
node['foo'](i.e.node.__getitem__()). The code searching for reference product edges was incorrect - when it was correct to search for both functional inputs and outputs, there was a severe performance degradation as all edges needed to be loaded and examined.
- Make
__version__a tuple again to avoid breaking downstream libraries
- Don't try to look up attributes in reference product edge if node type is not "process"
- Allow reference product exchange to be a functional input
- Delete upstream edges on node deletion
- Switch all ID generation to client side instead of database side, and use snowflake ids with a starting epoch of 2024-01-01.
- Add optional ability to serialize data state changes via DeepDiff. This implementation is well tested but is not recommended for casual use as it doesn't have any built-in conflict resolution or other functionality which would be needed to a production-level distributed data generation service using Brightway.
- Add signals based on blinker.
- Add possibility for location string normalization before geomapping array
- Pin previous version of
pintto skip frozen dataclass error
- Add error handling in updating migrations files
- #196: Fix copying over database metadata when copying database
- #193: Set node types when writing a
Database
This is a big change and could break some code:
-
It changes data when calling
.write()as it guarantees thattypeis always present -
Many datasets will have their type label changed from
processtoprocesswithreferenceproduct(e.g. all ecoinvent). Code with uses hard-coded "process" values will break. Seebw2data.configurationfor more details on labels you should expect. -
Only nodes with type
processwithreferenceproductwill be checked for implicit production. This shouldn't break anything as we changeprocesstoprocesswithreferenceproductif implicit production was going to be added. -
#194: Replace
printwith logging and add optionalstructlog -
Fix
calculation_setupsgetting out of sync on node and database deletion
- #192: Providing
Nodeobjects toprepare_lca_inputsraises an error
- #190:
BW2Exceptionshould inheritException(instead ofBaseException) - #187:
Except: passin databases metastore - #178: Use of
pydantic_settingsinconfiguration.pyallows for environment variables
- Allow
get_node(key=(<some tuple)) - Raise
UnknownObjectwhen writing LCIA methods referring to non-existent flows - Allow passing
Nodeobjects to LCIA method.write() - Allow iterating over LCIA methods
- Add additional labels
- Remove duplicate attr setting in
new_node
- Undo
isortreordering of__init__.pywhich caused circular import errors
- Switch from FTS4 to FTS5 for better availability across all OSes and publication platforms.
- Deprecated and removed
filterandmaskfunctionality from.search. Use list comprehensions for more complex search queries.
- Nobody saw nothing, and if you value your stuffed animals, it will stay that way.
- PR #176: Fix un-hashable error.
- Import multifunctional if available
- Use peewee instead of raw SQL when processing technosphere and biosphere exchanges, and properly exclude non-process nodes (i.e. those not included in
labels.process_node_types) from processed arrays. - Fix a bug with upstream exchanges introduced in
4.0.DEV44
- PR #175: add
check_typostoIOTableBackendwrite function. - Allow passing custom
Exchangesclass inActivity
- Add biosphere node default labels
- Add
labelsinto__init__namespace
- Fix some packaging bugs
- Fix some missing imports
- Update packaging
- Migrate from
pyfilesystem2tofsspec
- Add
get_multilca_data_objsfunction
- PR #170: Make string labels for matrix construction and typo detection user-configurable. Instead of fixed strings the labels which determine which values are used in matrices, which matrices they are used in, and what numeric sign they have is now completely configurable.
- Breaking change: Removed
include_substitutionfromNode.technosphereexchanges iterator. Substitution is production, and cannot logically be considered an input. - Breaking change:
bw2data.utils.TYPE_DICTIONARYwas removed. This hasn't been used in years. - Make
codeargument toDatabase.new_nodeoptional - Fix #139: Raise an warning when saving new nodes with type
technosphereorbiosphere
- Use rapidfuzz library for faster typo checks
- Add ability to skip typo checks for speed boost of large, known good, imports
- PR #160: Fix a type error in ProjectManager's
report()function - PR #146: Fix pipeline
- PR #143: Fix iterator over exchanges
- Allow custom datapackage processing by refactoring lookup dictionaries
- Prevent false positives cases where incorrect key is substr of valid key in
_check_keysfunction - Implement test cases for valid exchange key and type in
exchange_proxy.py - Add numpy docstrings in
typos - Add numpy docstrings in
proxies.savefunction
- Implement
ecoinvent_interfaceto compare strings
- Add
projects.change_base_directories - Update test decorator to use
projects.change_base_directories
- Fix a bug in
IOTable.writefunction
- Fix a missing test clause for optional dependencies
- Add warnings for common activity and exchange typos
- Fix for brightway-lca/brightway-live#39
- Make adding data to search index optional when writing
- Fix bug from withdrawn DEV22-24 line
- Allow writing databases without touching search index
- Remove
requestsfor easier WASM packaging
- #140: Search for single characters
- Purge
pyprindandpsutil
- Remove
fastenersand write locks - Remove
docoptandbw2-uptodate.py - Substitute
platformdirsforappdirs - Remove
psutildependency
- Yanked due to insufficient testing and documentation
- Add
Exchanges.to_dataframe
- PR #109: Export edges and activities to dataframes
- PR #105: Complete revamp of IO Table functionality
- PR #104: Fix
Exchange.lca() - Fix #95
- Moved
wurstextraction functions tobw2data
- Fix and test export CSV metadata from databases during datapackage creation
- Improve lookup of activity classifications and properties
- Add
Activity.rp_exchangefor easier access to reference product exchange Activity['foo']will now also lookup reference product classifications and properties
- Add
Database.new_node
- Add
Database.set_geocollections
- Change behaviour of
.get()and.get_activity()to allow passing arbitrary filters and raise error if multiple results found - Add
Activity.consumers()andActivity.producers(). technosphere()no longer returns substitution exchanges by default (but still does ifinclude_substitution=True); substitution exchanges are included by default inproduction.- Add
.datapackage()convenience method for processed datastores
- Only need geocollections for process nodes
- Can pass
Activityobjects toget_activity - Add
delete_duplicate_exchangesutility function - Automatically add geocollections for easier regionalization setup
- Removing caching database lookups, it was causing pain and confusion
prepare_lca_inputsshouldn't require a demand (e.g.switch_methodin LCA class)
- Change bw2io migrations update to not require bw2io installation
- Add reprocessing migration for all data
- Fix bw2io issue #115: FileNotFoundError in migrated project
- CI fixes
- Compatibility with downstream changes for Brightway 2.5
Fix bug in prepare_lca_inputs to pass bw_processing packages instead of PyFilesystem2 objects.
Fix bug for prepare_lca_inputs without remapping dicts.
Removing the Python 2 compatibility layer allows for much cleaner and more compact code, and the use of some components from the in-development Brightway version 3 libraries.
This allows for cleaner and more consistent code. Includes things like projects.dir.
These backends were implemented many years ago, and most of the current code already assumes the SQLite backend.
The peewee directory is removed, and most of the code now lives in bw2data.backends. LCIBackend is removed, and now SQLiteBackend directly subclasses ProcessedDataStore.
We now use bw_processing to create processed arrays. Processed arrays are compressed directories (because there is a metadata file as well, and possibly multiple array files). All databases, methods, etc. will need to be reprocessed, but this happens automatically via a data migration.
bw_processing has a completely different API, and LCA objects no longer have a single set of parameters (like tech_params) for each matrix - instead, they have data resources, which offer more flexibility, but also more complexity. See the bw_processing, matrix_utils, and bw2calc documentation.
Using integer IDs is the preferred way to identify activities and products in Brightway 3. You can now easily get the integer id of an activity:
>>> a = bw2data.Database("something").random()
>>> a.id
19014And use the integer ID in the get functions:
>>> bw2data.get_activity(19014)
'treatment of aluminium in car shredder residue, municipal incineration' (kilogram, RoW, None)
>>> bw2data.Database("something").get(19014)
'treatment of aluminium in car shredder residue, municipal incineration' (kilogram, RoW, None)You can also call get_id on activity keys:
>>> bw2data.get_id(a)
19014
>>> bw2data.get_id(a.key)
19014You can still import mapping, but this will just look up the IDs from the SQLite database. There is no longer a separate file.
This change means that you can no longer add exchanges or characterization factors which reference activities that don't (yet) exist.
IOTableBackend.writearguments have changed to(products, prod_exchanges, tech_exchanges, bio_exchanges).bw2data.utils.safe_filenamewas moved tobw_processingDatabase.getis removed (thoughDatabase('foo').get()still works). Useget_activityinstead.
- Fixed invalid variable name creation
Merged PR #19: Fix activityparam rename.
- Merged multiple pull requests (#12, #13, #14, #15, #16, #17, #18) from Daniël de Koning related to improving the handling of parameters, as part of his work on including parameterization in the Activity browser.
- Remove temporary directories after tests finish
- PR #11: Fix for searching with stop words
- Fix
collections.abccompatibility with Python 3.8
- Make index creation not raise error if index already exists
- Fix #60: No SQLite index creation after switching projects
- Merged PR #9: Better handling of non-unique parameter names
- Fix #56: Name conflicts with multiple dummy parameters
- Fix bug with geocollections and search indices
- Eliminate inconsistency between use of
nameandvariableby always usingname
- Remove print debugging statements
- Compatibility with Peewee 3 breaking changes
- Better find symbol name dependencies in exchange formulas
- Minor compatibility changes for parameters to make unified API
- Improve performance of
random(#47) - Added
dynamic_calculation_setups - All data in search engine stored in lowercase (#35)
- Fixes to writing sqlite databases for better interaction with user interfaces (#53)
- Add support for hierarchical parameters and formulas (expressed as strings), with automatic and recalculation of dependencies
- Make Activity.upstream() more flexible
- Fix bugs in
merge_databases
- Fix bug where
negativevalue wasn't used in exchange proxy uncertainty dictionaries
- Add database merging function (bw2data.utils.merge_databases)
- Fix license text
- Specify encoding of license file, and then don't. Yeah computers.
- Remove dependency on bw2io
- Include substitution types in
.technosphere()iterator. Can be excluded withinclude_substitution=False.
- Write-only locks are now optional and disable by default
- Removed
projects.current. Exchangesis now consistently ordered
- Specify a sensible order for sorting processed arrays
- Fixed bug with Activity.copy()
- Fixed some bugs with database filtering
- Use consistent sorting for all
DataStoreobjects. However, this sorting is not guaranteed across machines. - Use
np.saveinstead of pickling for processed arrays. - Added
projects.output_dirand environment variableBW2_OUTPUT_DIR. - Removed deprecated functions in
config. - Add field
codeto search index.
- Changes to improve testing for bw2data and bw2calc
- Fix some places where set_current wasn't introduced
- Rework initialization of projects and add projects tests
- Moved tests to main directory
Windows tests are failing due to naughty strings being used for project names.
- Deprecated
projects.current = 'foo'in favor orprojects.set_current('foo') - Added ability to switch to read only project with
projects.set_current('foo', writable=False) - Removed separate write of topomapping files from inventory databases. All topology handling is internal to bw2regional
- Fixed bug where
download_filewouldn't raise an error is resource was not found.
- Fix database writes not propagating to search index
- Added continuous integration tests on Windows
- Fix bug when iterating over projects
- Better
__str__for metadata - Make projects sortable
- Allow forcing writes with
projects.enable_writes(force=True)
- Bugfix release to add unstated dependency of
pyprind
2.0 brings massive changes to how datasets are stored and searched. The first big change is a new default backend, using peewee and SQLite3. This backend has a nicer API, faster random access, and reduced memory consumption. Here are some examples of new usage patterns:
- FEATURE: New backend, sqlite, which is the default. Should massively reduce memory consumption in most cases, as entire databases don't need to be loaded.
- FEATURE: Backend now return activity and exchange proxies instead of raw data, making for easier manipulation and construction.
Note: Both packages bw2search and bw2simple are obsolete - their functionality is now included in bw2data by default.
Data cannot be directly migrated from bw2data < 2; instead, databases should be exported as BW2Package files and then re-imported.
- BUGFIX: JSONDatabases are now JSON-serializable. Database variants must now support the keyword argument
as_dict, and return an actualdictifas_dict=True.
- Improve SimaPro and Ecospold2 imports
- BUGFIX: Added missing
unidecodedependency. - BUGFIX: Remove error when bw2calc is not installed.
- BUGFIX:
safe_savenow works on Windows.
- FEATURE: Add SimaPro ecospold 1 imports, and create a new import "flavor" called "SimaPro8" that can handle the new way SimaPro breaks ecoinvent 3 activity names.
- FEATURE:
utils.safe_savemakes sure a file write is successful before overwriting known good data. - CHANGE: Lots of documentation improvements.
- CHANGE: Import comments by default in ecospold 1 & 2. Remove
import_comments.pyfile. - CHANGE: Added some ecoinvent 3 units to
normalize_units.
- FEATURE: Add
backends.utils.convert_backendutility function to switch between database backends. - FEATURE: Added Ecospold 1 & 2 comment importers (
io.import.add_ecospold1_commentsandio.import_comments.add_ecospold2_comments). Comments are currently not imported by default. - CHANGE: Ecospold 1 & 2 importers now store file directory as
directoryin metadata. - CHANGE: Each Database should specify its
backendattribute.
- BUGFIX: Don't die if
xlsxwriternot installed.
- FEATURE: Add MATLAB LCI matrix exporter.
- FEATURE: Add
make_latest_versionmethod for SingleFileDatabases, to make reverting easier. - BUGFIX: Make sure
uncertainifycan handle negative amount values.
- CHANGE: Automatically set
num_cfsfor methods andnumberfor databases when.write()is called.
- BUGFIX: Release memory during
Updates.reprocess_all_1_0.
- CHANGE: Ecospold2 importer is now more resilient to incorrect input data.
- BUGFIX: uncertainify now correctly handles amount <= 0.
- Small documentation fixes.
bw2-uptodate.py is required for this update.
Default values for various attributes need to be added when not previously specified.
- FEATURE: Pluggable LCI backends. Two backends are provided - SingleFileDatabase and and JSONDatabase, and others can be easily added. A new notebook shows how to use JSONDatabase.
- FEATURE: Ecospold2 importer is out of alpha status as of Ecoinvent 3.1.
- FEATURE:
bw2-uptodateshould now work without PATH hassles on windows. Name changed frombw2-uptodate.py. - FEATURE: Searching databases is better documented and tested. A new notebook shows searching examples.
- BREAKING CHANGE: The "in" operator in searching is now "has" - the previous semantics were simply incorrect.
- CHANGE: Database exchanges without
typenow raise UntypedExchange error when processed. - CHANGE: Database exchanges without
amountorinputnow raise InvalidExchange error when processed. - CHANGE: The order of database exchanges in processed arrays is sorted is changed.
- CHANGE: LCI database format is now more flexible, and almost all required elements are removed. For example,
{}is now a valid LCI dataset. - BUGFIX: Allow unicode in
utils.safe_filename. - BUGFIX:
reset_meta()now also reset config preferences.
- CHANGE: Improve resiliency of SimaPro import.
- BREAKING CHANGE: Database 'depends' is now calculated automatically when calling Database.process().
bw2-uptodate.py is required for this update
- FEATURE: Added
Database.filepath_intermediateandDatabase.filepath_processedfor easier access to raw data files. - BREAKING CHANGE: All importers now produce unicode strings. Before, the SimaPro importer produced Latin-1 strings, while the XML importers produced UTF-8.
- CHANGE:
Database.process()now usesobj.filename, notobj.name, as this is not always safe for filenames.
- FEATURE: Utility functions to view process datasets in web browser
- FEATURE: utils.web_ui_accessible tests if web UI is running and accessible
- CHANGE: SimaPro importer can now add unlinked exchanges as new process datasets
- CHANGE: New preference key: "web_ui_address"
- BREAKING CHANGE:
Database.processskips exchanges iftypeis notprocess. - FEATURE:
Database.list_dependentstraverses datasets to get linked databases. - CHANGE: Query.repr always returns unicode strings.
- CHANGE: SimaPro importer can now import input and output comments, including multiline comments
No changes, just messed up packaging...
bw2-uptodate.py is required for this update
- CHANGE:
BW2Package.export_objnow usesobj.filenameinstead ofobj.namefor filepath of backup file (needed for LCIA methods). - CHANGE:
categoriesis no longer required byutils.activity_hash. - CHANGE:
Database.copy()no longer emits a not registered warning. - CHANGE:
Database.copy()makes a deep copy of data before modification. - CHANGE:
bw2data.__init__no longer imports theioandproxiesdirectories, to avoid namespace conflicts with io standard library package.
- BREAKING CHANGE:
Database.process()now only includes datasets with typeprocessin constructing geomapping array.
##0.12.2 (2014-02-04)
- CHANGE: BW2Package import file ignores warnings
New BW2Package format
The new BW2Package is not specific to databases or methods, but should work for any data store that implements the DataStore API. This allows for normalization, weighting, regionalization, and others, and makes it easy to backup and restore.
bw2-uptodate.py is required for this update
The algorithm to create filenames was changed to prevent illegal characters being used. See utils.safe_filename.
bw2-uptodate.py is required for this update
The update code filename was changed to updates.py, and dramatically simplified. Code was organized and moved to an Updates class. All functionality was removed from utility scripts and bw2-uptodate.py. Fresh installs should not have erroneous "updates needed" warnings.
data_store.DataStore defines a template for all data stores which could be processed into matrix data, and provides a lot of functionality for free. New objects subclass DataStore or ImpactAssessmentDataStore, and need only define their unique data fields, metadata store, and validator. Abstracting common functionality into a simple class hierarchy should also produce fewer bugs.
- BREAKING CHANGE: The filenames for LCIA methods are now derived from the MD5 of the name. This breaks all method abbreviations.
- BREAKING CHANGE: The filename and filepath attributes in SerializedDict and subclasses moved from
_filenameandfilepathtofilenameandfilepath - BREAKING CHANGE: Register for all data store now takes any keyword arguments. There are no required or positional arguments.
- BREAKING CHANGE: Database.process() doesn't raise an AssertionError for empty databases
- FEATURE: Database.process() writes a geomapping processed array (linking activity IDs to locations), in addition to normal matrix arrays.
- FEATURE: Tests now cover more functionality, and should allow for more worry-free development in the future.
- CHANGE: Database datasets are not required to specify a unit.
- CHANGE: The default biosphere database is no longer hard coded, and can be set in config.p['biosphere_database']. The default is still "biosphere".
- CHANGE: The default global location is no longer hard coded, and can be set in config.p['global_location']. The default is still "GLO".
- CHANGE: Ecospold 1 & 2 data extractors now only have classmethods, and these classes don't need to be instantiated. A more functional style was used to try to avoid unpleasant side effects.