Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Consolidate code structure #26

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

feat: Consolidate code structure #26

wants to merge 10 commits into from

Conversation

pesap
Copy link
Collaborator

@pesap pesap commented Mar 17, 2025

Code Structure Changes

  • Reorganized methods fromapi.py and sqlite.py to plexosdb.py and db_manager.py. plexosdb.py includes only the API to the application, e.g., get_object, add_object and db_manager the API to SQLite only.
  • Enhanced documentation to all the methods
  • Database Interface Improvements with accurate transaction handling, context manager and rollbacks
  • Added class factory method for PlexosDB from_xml() for easier instantiation from an XML file,
  • Added plexos version property,
  • Consistent parameter naming and method signatures
  • Chunked data processing for large datasets
  • Memory-efficient iterators for large result sets

Remaining methods to migrate

  • version
  • backup_database - Backup the in-memory database to a file
  • add_memberships_from_records - Bulk insert multiple memberships
  • add_properties_from_records - Bulk insert multiple properties
  • update_property - Update property values for objects
  • get_scenario_id - Get scenario ID by name
  • export_to_xml - Export database to XML format
  • copy_object - Copy an object with its properties
  • delete_object - Delete an object from the database
  • update_object - Update object attributes
  • get_objects - Get objects with filtering options
  • check_membership_exists - Check if membership exists
  • add_band - Add a band to a property data record
  • add_text - Add text data to a property
  • delete_property - Delete properties from objects
  • update_properties - Update multiple properties
  • get_property_unit - Get unit for a property
  • add_attribute - Add attribute to an object
  • add_metadata - Add metadata to entities
  • get_attribute - Get attribute details
  • get_attributes - Get all attributes for an object
  • check_attribute_exists - Check attribute existence
  • add_report - Add a report configuration
  • list_reports - List all defined reports
  • export_to_csv - Export tables to CSV files
  • add_time_slice - Add time slice definition
  • validate_database - Validate database integrity
  • list_scenarios - List all scenarios
  • list_models - List all models
  • list_units - List all available units
  • list_classes - List available classes
  • list_collections - List available collections
  • iterate_properties - Iterator for properties
  • add_custom_column - Add custom columns
  • add_datafile_tag - Add file tags
  • add_variable_tag - Add variable tags
  • set_date_range - Set date range for data

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 85.13120% with 102 lines in your changes missing coverage. Please review.

Project coverage is 90.14%. Comparing base (b4cfc1f) to head (abd4aad).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/plexosdb/plexosdb.py 80.41% 85 Missing ⚠️
src/plexosdb/xml_handler.py 81.57% 7 Missing ⚠️
src/plexosdb/db_manager.py 97.89% 4 Missing ⚠️
src/plexosdb/utils.py 72.72% 3 Missing ⚠️
src/plexosdb/sqlite.py 50.00% 2 Missing ⚠️
src/plexosdb/enums.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   93.97%   90.14%   -3.84%     
==========================================
  Files           7        9       +2     
  Lines         880     1552     +672     
==========================================
+ Hits          827     1399     +572     
- Misses         53      153     +100     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cursor.execute(query_string)

return cursor.fetchall()
except sqlite3.Error:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This except clause is a no-op.

@pesap pesap changed the title Ps/fix get objects feat: Consolidate code structure Mar 18, 2025
@pesap pesap requested a review from kodiobika March 18, 2025 06:18
@pesap pesap self-assigned this Mar 18, 2025
@pesap pesap force-pushed the ps/fix_get_objects branch from a17a29d to abd4aad Compare March 24, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants