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

Import Recipes Errors #740

Open
MichaelPersico opened this issue Mar 23, 2023 · 6 comments
Open

Import Recipes Errors #740

MichaelPersico opened this issue Mar 23, 2023 · 6 comments

Comments

@MichaelPersico
Copy link

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
Copy link
Contributor

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
Copy link
Author

@matty0ung
Copy link
Contributor

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:

  • On line 38, it says the style type is "Pale Ale", but this is not one of the allowed values for this field in BeerXML. The permitted values are “Lager”, “Ale”, “Mead”, “Wheat”, “Mixed” or “Cider”. I changed it to "Ale".
  • In various places, boolean fields are specified as "false" or "true". This not permitted in BeerXML. The specification says a boolean is "either TRUE or FALSE, with TRUE and FALSE in capitals". I did a global search and replace for ">false<" -> ">FALSE<" (9 replacements) and ">true<" -> ">TRUE<" (2 replacements).
  • On line 126 and elsewhere, the IBU_GAL_PER_LB field is specified as "NaN". This is not permitted in BeerXML. The specification says it is a floating point field and defines a floating point value (in a slightly circular way) as "a floating point number, usually expressed in its simplest form with a decimal point as in "1.2", "0.004", etc... Programs shall endeavor to store as many significant digits as possible to avoid truncating or losing small values.". The IBU_GAL_PER_LB is optional, so I deleted all the lines with "<IBU_GAL_PER_LB>NaN</IBU_GAL_PER_LB>" (4 replacements).

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Contributor

FYI, I just made some changes in #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.

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

2 participants