Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
312 stars 134 forks source link

Import Recipes Errors #740

Open MichaelPersico opened 1 year ago

MichaelPersico commented 1 year ago

I'm trying to import recipes from Brewfather and Brewer's Friend. Beer XML from both will not import into Brewtarget. Error pops up and nothing gets imported. Don't know if this possible but figured I'd ask anyway. Using 3.0.7 on a Windows 10 machine. Attaching regular and debug logs. brewtarget.log brewtarget_2023_03_23_11_43_49_799.log

matty0ung commented 1 year ago

Sorry to hear you're having problems. Could you upload one or more of the XML files you're trying to import? The error logs tell me where in the file Brewtarget is having difficulty parsing things, but, without the file itself, it's hard to tell what the root cause of the problem is.

MichaelPersico commented 1 year ago

Here are the 2 I tried as as test, one from Brewfather and one from Brewer's Friend.

https://drive.google.com/file/d/1G8QQEo-wmDEbOOldETSq3zv34b3C9ff-/view?usp=share_link https://drive.google.com/file/d/1MeIoKA5QXPfh4cD7SRcUQI2IEWHcD6Qw/view?usp=share_link

matty0ung commented 1 year ago

Thanks for that. That's super helpful.

I looked at the Brewfather_BeerXML_SampleBlondeAle_20230317.xml file. The reason you're seeing errors is that there are a number of places where the file does not follow the BeerXML standard. (As @mikfire will attest, the BeerXML standard does rather suck in a number of ways, but I think it's fair to say we make greater efforts to conform to it than many other programs.) Anyway, I edited the XML file as follows to fix the problems:

The fixed file is attached. (You'll want to remove the .txt suffix. It's just there to allow it to be an upload on github.) Fixed Brewfather_BeerXML_SampleBlondeAle_20230317.xml.txt

I'll have a look at the other file soon (hopefully tomorrow). In a bit of a rush this evening.

MichaelPersico commented 1 year ago

Thanks for the help. I figured it was something to do with formatting as I changed false/FALSE and got past the first error but another came up.

Don't worry about fixing the other file as this was just an experiment.

Ironically, I was hoping to save time by not having to manually add ingredients into Brewtarget that aren't included. Thought I could make the recipe in either of the others and just export/import the xml file. If I'm going to have to find errors and edit every file then its probably just better to manually add the ingredients to Brewtarget anyway.

matty0ung commented 1 year ago

It is annoying when there are a lot of things to fix. At some point I would like either to make our BeerXML import more forgiving of easy-to-fix errors in other implementations (eg the true/false vs TRUE/FALSE stuff), or else to provide a separate script that corrects such errors.

In the long run, once Brewtarget and (hopefully) other programs support BeerJSON, it should be a lot easier to do such data sharing. I also have an ambition to improve the list of ingredients that we ship with.

matty0ung commented 11 months ago

FYI, I just made some changes in https://github.com/Brewtarget/brewtarget/pull/767/ which mean we should be more accepting of true and false in BeerXML files. Unfortunately, it looks like Brewfather also does some other strange things in its BeerXML output. In particular, in the SampleBlondeAle file, it has "NaN" for the value of IBU_GAL_PER_LB. I think we could extend our code to accept this (and decide that such a value means "not specified"), but it's a slightly bigger change (because it also needs work in the C++ code, not just the schema file), so I'll probably come back to it a future point.