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

Write function to generate curation #26

Open
dr-rodriguez opened this issue Mar 10, 2020 · 1 comment
Open

Write function to generate curation #26

dr-rodriguez opened this issue Mar 10, 2020 · 1 comment

Comments

@dr-rodriguez
Copy link
Owner

Given a reference, have a function that can be run to provide a curation dictionary. This would search all possible parameters for that reference and if it finds some, would write a curation dictionary containing this. Long term we may want to implement a sorted list of references, but for a first pass a single reference is enough.

The curation dictionary can then be saved in the standard way to a file and we may want to consider this as a delta applied to an existing curation, both of which can be handled by a utility function.

dr-rodriguez added a commit that referenced this issue Mar 10, 2020
… database contents and reading/writing it to a file #26
@dr-rodriguez
Copy link
Owner Author

@eteq This is now implemented and it was actually not too difficult to do it recursively. Currently, a single reference is used per parameter, though, which we may want to revisit.

You can use the db.generate_curation method as follows:

from galcat.core import *
db = Database(references_file='data_references.json')
# Simple case:
curation = db.generate_curation('Ref_1')
# Adding to an existing curation (ie, overwritting):
curation = db.generate_curation('Ref_2', existing_curation=curation) 
# Creating from a list:
curation = db.generate_curation(['Ref_1', 'Ref_2'])

The last case works by recursively calling itself with a reversed list, resulting in Ref_1 being prioritized over Ref_2 if any cases are found. Since only a single reference is saved per parameter this is currently somewhat limited, but can still be useful.

Curation dictionaries can be saved with the write_curation() function and read from a JSON with the hidden function _read_curation()

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

No branches or pull requests

1 participant