Skip to content

Refactor ID code#477

Merged
tsmbland merged 6 commits intomainfrom
id
Apr 14, 2025
Merged

Refactor ID code#477
tsmbland merged 6 commits intomainfrom
id

Conversation

@tsmbland
Copy link
Copy Markdown
Collaborator

@tsmbland tsmbland commented Apr 11, 2025

Description

A few changes to tidy up handling of IDs

  • Move id-related code into a new module
  • Remove agent_id from AgentSearchSpace
  • Remove process_id from ProcessParameter
  • Remove the IntoIDMap trait and method as this was only used once

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 86.79245% with 7 lines in your changes missing coverage. Please review.

Project coverage is 95.13%. Comparing base (8876b7b) to head (a2eab40).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/input/agent/search_space.rs 0.00% 2 Missing and 1 partial ⚠️
src/input/process/flow.rs 93.75% 1 Missing and 1 partial ⚠️
src/input/process/parameter.rs 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #477      +/-   ##
==========================================
+ Coverage   95.10%   95.13%   +0.02%     
==========================================
  Files          35       36       +1     
  Lines        4947     4931      -16     
  Branches     4947     4931      -16     
==========================================
- Hits         4705     4691      -14     
  Misses        120      120              
+ Partials      122      120       -2     

☔ 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.

@tsmbland tsmbland marked this pull request as ready for review April 11, 2025 14:50
@tsmbland tsmbland requested review from alexdewar and Copilot April 11, 2025 14:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Copy link
Copy Markdown
Member

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

LGTM! Nice cleanup.

The IntoIDMap trait did have some more users at one point, but it doesn't make sense to keep it around if there's just the one left.

for search_space in iter {
for search_space_raw in iter {
let search_space =
search_space.to_agent_search_space(process_ids, commodities, milestone_years)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's actually quite common to reuse variable names like this in Rust (it's less dangerous than in e.g. Python) but this is ok too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Cool, yeah probably not clear why I did this but was just because later on I use agent_id from search_space_raw because search_space no longer has agent_id. So I just needed to keep seach_space_raw in the namespace. (Equally could have extracted agent_id before converting search_space_raw to search_space)

@tsmbland tsmbland merged commit 441197f into main Apr 14, 2025
7 checks passed
@tsmbland tsmbland deleted the id branch April 14, 2025 15:08
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