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

DB Write and read give different results #50

Open
gymzombie opened this issue Apr 17, 2023 · 0 comments
Open

DB Write and read give different results #50

gymzombie opened this issue Apr 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@gymzombie
Copy link
Contributor

gymzombie commented Apr 17, 2023

Not sure if this is a bug or intended functionality.

I create a model and write it to the database. (v1)
I decide I want to change the parameters of that model and adjust the values, then write it to the database. (v2)
I load the model from the database, and the output shows the model for v1.

Sample code to reproduce:

# Create an initial model
model = FairModel('System 1, Risk A')
model.bulk_import_data({
    'Loss Event Frequency': {'mean':.3, 'stdev':.1},
    'Loss Magnitude': {'constant': 5_000_000}
})
model.calculate_all()

# Create a database file and store that model
db = FairDatabase('pyfair.sqlite3')
db.store(model)

# Create a new version of that model
model = FairModel('System 1, Risk 1')
model.bulk_import_data({
    'Threat Event Frequency': {'low':.3, 'mode':.6, 'high':.9},
    'Vulnerability':{'constant':.5},
    'Loss Magnitude': {'constant': 5_000_000}
})
model.calculate_all()

# Write the updated version of that model to the database
db.store(model)

# Load the model
reconstituted_model = db.load('System 1, Risk A')
reconstituted_model.calculate_all()

fsr = FairSimpleReport([reconstituted_model])
fsr.to_html('output.html')

This also might just be a style/documentation issue? Since we read and write based on the model name, but the database reads and writes based on the UID, it's just unexpected behavior for a new user.

@cneskey cneskey added bug Something isn't working enhancement New feature or request and removed bug Something isn't working enhancement New feature or request labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants