Implementing cell value type checking #29
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
github.com/banillie/bcompiler-engine@26b63b6e63Prompted by
github.com/banillie/bcompiler-engine@26b63b6e63, this issue is to discuss the implementation of cell value type checking in bcompiler-engine.bcompiler-enginecurrently accommdates a "type" column in the datamap which allows a user to specify the expected data type in the cell being targeted, to allow for type-checking to be carried out during theimportphase. The underlying JSON structure that is extracted from the spreadsheet contains a "type" attribute (I will add details of the location of the code, etc later) which reflects basic types currently allowed in the datamap, such asTEXT,DATEandNUMBER(again, I will clarify later).The objective of this feature is to implement type-checking for the user, therefore the following questions needs to be answered:
DATEtype, you might want to restrict dates before or after a certain date; strings less than a certain length, numbers within a range. Such considerations go beyond simple type-checking into rule-creation. If kept simple at first, this is a useful potential addition that should be provided for early on.datamapsto switch the feature on or off (e.g.-tor--type-checking) for exampleimport,templates, etc.There will be other concerns which I will update here!
Nice list of questions Matt. lets discuss them next week. I think it will be good to throw some of these out to the team also, to see what they want.
have sent to the team and asked them to specify requirements for 1-5, but we probably need to discuss 6-10 first. do you want to have a specific time for this, or do it as part of our weekly coding session?
Useful to get the team's view on this. I think their input on
1,4and5are most important - the other things are more for us from a development point of view. Happy to discuss on here and during our weekly session.6and7are key and I need to lead on that, and happy to do so. The best approach would be for me to try to have a look at the code before our session and re-familiarise myself with the structure and come up with some preferred options, and then explain in this issue, pointing at code if possible. When we meet, we can discuss the options. If you're looking at the code in the meantime, feel free to pitch anything into this thread as you go on, including questions, ideas, suggestions, etc.Current type validation code inside bcompiler-engine - main objects and functions
Implementation Code
Types are coded as
DatamapLineValueTypeobjects, which is an Enum, from here:github.com/yulqen/bcompiler-engine@254f306a6e/engine/domain/datamap.py (L11-L20)Data extracted from a spreadsheet is wrapped in a
TemplateCellobject, one per cell.TemplateCellis defined here:github.com/yulqen/bcompiler-engine@cb9e6fb87d/engine/domain/template.py (L7-L32)Types are assigned to values when being extracted from the spreadsheet, here:
github.com/yulqen/bcompiler-engine@254f306a6e/engine/utils/extraction.py (L437-L490)which happens inside a function,
template_reader, called as a multiprocess from here:github.com/yulqen/bcompiler-engine@6b88864516/engine/use_cases/parsing.py (L227-L233)Relevant tests
template_readeris tested here:github.com/yulqen/bcompiler-engine@6b88864516/tests/test_datamap_parser.py (L60-L79)which is a good spot to put the debugger to examine the
datavariable, which is a dictionary containing data from a single sheet.and here:
github.com/yulqen/bcompiler-engine@6b88864516/tests/use_cases/test_master_from_org_templates.py (L32-L42)@banillie - This is now almost ready for v1.1.0 which is coming out very soon. As ever, would appreciate a bit of testing and feedback!
@banillie - v1.1.0 of datamaps has been put out. See the CHANGELOG for details.
--rowlimitand--inputdir)-v)@yulqen going to test it now. Will let you know.
Update:
datamaps import templates runs well. row limit set to 500 automatically.datamaps import templates -m --rowlimit 300workeddatamaps import templates -vtold me I needed to have a type column. Which my dm.cvs doesn't, so workinghave some issue with the --inputdir argument as below
datamaps import templates -m -d ../Q3_dm_import.csv --inputdir ~/Documents/datamaps/19-Jan-21 10:12:42: INFO - Row limit is set to 500.19-Jan-21 10:12:42: CRITICAL - Cannot find /home/will/Documents/datamaps/../Q3_dm_import.csvthe
-dand--inputdirarguments seem to be conflicting with each other. probably because I'm not entering properly.This is now fixed in datamaps v1.1.1.