Skip to content

WIP: Optimizations and Fixes#4

Open
dwr-rsahar wants to merge 3 commits intodevelopmentfrom
feat-load-from-cache
Open

WIP: Optimizations and Fixes#4
dwr-rsahar wants to merge 3 commits intodevelopmentfrom
feat-load-from-cache

Conversation

@dwr-rsahar
Copy link
Contributor

I went through the comments of the previous pull request and cleaned up the code/comments. There is a single function for load_date_map and load_df_dv_orig called cache_read_csv. This serves as a general purpose cached csv reader. Went through the other functions and made sure they were utilizing this new function instead of the older methods. Hopefully everything looks good!

Copy link
Contributor

@dwr-zroy dwr-zroy left a comment

Choose a reason for hiding this comment

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

Looks close.

Another small note, this is a pretty unhelpful commit message. Without additional context, it doesn't describe what changes were made.

Comment on lines 14 to 24
# Load variable definitions from yaml file once and keep in memory
@lru_cache(maxsize=1)
def load_var_dict():
with open("constants/dvars.yaml", "r") as file:
return yaml.safe_load(file)

# Load state variable definitions from yaml file once and keep in memory
@lru_cache(maxsize=1)
def load_svar_dict():
with open("constants/svars.yaml", "r") as file:
return yaml.safe_load(file)
Copy link
Contributor

Choose a reason for hiding this comment

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

These are still separate functions.

@dwr-zroy dwr-zroy added the enhancement New feature or request label Jul 31, 2025
@dwr-rsahar
Copy link
Contributor Author

Regarding the two functions, load_var_dict() and load_svar_dict(), I've made some changes. You pointed out that they practically do the same thing, which is just loading YAML files and caching them, so I created a single, reusable function: load_yaml().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants