Replies: 1 comment 2 replies
-
|
I'm not sure about the first idea, I think you're wanting to make Now, I also agree we need a high-level class that reserves an ID, create the repo on github, downloads it, etc. and that's OpenPechaGitRepo. So I would instead do: pecha = OpenPechaFS(<path_to_pecha>) # no changepecha = OpenPechaGitRepo(base_path, <pecha_id>=None, <rev>="main") # downloads pecha from github if it exists, otherwise create one with the id. If pecha_id is None, reserves a new idNote that if we add the Also, I think the creation of a new openpecha id should not be hidden deep in the pecha_id = OpenPechaGitRepo.reserve_new_id() # reserves a new id that is not currently in use on githubNote that in ocr_formatter you can then use I think having And finally, I think it would be much cleaner if we had a method What do you think? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How it's leaky abstraction?
output_pathis the path to store all the pechas created by the formatters. It defaults to~/.openpecha/pechas/But in OCRFormatter's
create_opf, theoutput_pathis passed aspathofOpenPechawhich isopf_pathnow, the caller code, eg
OCR-pipelines, needs to createopf_pathfor pecha, which in turn requires to createpecha_id. But thepecha_idgeneration is handled byMetadata, which is only created in theFormatters. So, with currently implementation, pecha will be saved atopf_pathcreated by caller code. Since, it's doesn't have access toMetadatacreation, metadata will generate new pecha_id. Now, we ended up with different,pecha_idinopf_pathand `meta.yml.Therefore, I think this is a leaky abstraction. The caller code only needs to provide where to store the all the pechas to the Formatters.
Why this problem exists?
I think, there is two scenarios,
creatingandloadingpecha and we don't have clean way to handle these two.Solution
1. When
Creatingnew pechasWe should initialise the
pechaobject with the actual data like,base,layers,metadata, etc.When saving, we should provide
output_pathwhich is the parent path of the pecha path like{output_path}/{pecha_id}/{pecha_id}.opf. Now theoutput_pathis configurable, which is desired behaviour.2. When
Loadingexisting pechasI think we should go with
classmethods, for eg:Beta Was this translation helpful? Give feedback.
All reactions