Conversation
| f"Unknown consignment generation method: {generation_method}" | ||
| f"Unknown consignment generation method: {generation_method} or " | ||
| f"input file type: {config['input_file']['file_type']}" |
There was a problem hiding this comment.
This will fail for unknown generation_method (e.g., param_based) and config['input_file']['file_type'] not provided. One way around it would be to extract config["input_file"]["file_type"] ahead of time if available and use None otherwise. This will make the code more robust overall because the case of generation_method == "input_file" and forgotten config["input_file"]["file_type"] is not handled at all.
| filename=config["input_file"]["file_name"], | ||
| ) | ||
| elif (generation_method == "input_file") and ( | ||
| config["input_file"]["file_type"] == "variable packaging" |
There was a problem hiding this comment.
We use parameter_based for method and variable packaging here. It is just for consistency since it is key. input_file is both value and key, so it is input_file in both cases. I don't have a strong opinion, though. In PoPS Core, we ended up supporting all different spellings, but implementing it here would mean some extra work.
| items_per_box = int(record["ITEMS_PER_PACKAGE"]) | ||
| unit = record["QUANTITY_UNIT"] | ||
|
|
||
| # Generate items based on quantity in records. | ||
| # Quantity unit must be stems/items. | ||
| if unit in ["Stems", "Items"]: | ||
| num_items = int(record["QUANTITY"]) | ||
| else: | ||
| raise RuntimeError(f"Unsupported quantity unit: {unit}") |
There was a problem hiding this comment.
Can you please describe here, in the class docstring, or the PR description on the difference between this class and AQIM?
I can see the two classes are similar and we can resolve some de-duplication some other time, but it would be good to have clear specification of what are the differences.
|
Thanks for this review, @wenzeslaus! I'll get these changes incorporated shortly. |
Created a new file-based consignment type that gets the item_per_box value from each record in the input file, allowing packaging to vary. Added sample data for variable packaging consignments and AQIM consignments. Used data swapping and commodity/port name alteration to anonymize sample data.