brendanhay/gogol

ModelVersion parsing fails with toolresult and vision

Opened this issue · 2 comments

Hi, great library!
I tried to generate this library in my computer but it failed, it cannot parse "v1beta3firstparty" version for toolresult and "v1p1beta1" for vision. After removing those folders from models it generate the library without any problem.

I tracked this down to what I think is the code causing the problem, for me the error I get:

gogol-gen: v1beta3firstparty -> endOfInput
CallStack (from HasCallStack):
  error, called at src/Gen/Types.hs:167:16 in main:Gen.Types

Looking at this code:
https://github.com/brendanhay/gogol/blob/develop/gen/src/Gen/Types.hs#L167
then looking at parseVersion:
https://github.com/brendanhay/gogol/blob/develop/gen/src/Gen/Types.hs#L119-L140
I don't think this code can deal with these two dir formats. There are now three failures, these are the ones I had to remove to get my latest PR to build:

< --model=model/toolresults/v1beta3firstparty/toolresults-api.json
< --model=model/vision/v1p1beta1/vision-api.json
< --model=model/vision/v1p2beta1/vision-api.json

I wrote this: polynomial@5e77a7e
But then realized in the repl that I don't think it does what we want. Although, that lead me to ask, what is it we do want?

For this directory: v1beta3firstparty should this:

> parseVersion "v1p1beta1" 

return this:

Right (ModelVersion 1.0 (Just (Beta (Just 1) Nothing)))

or

Right (ModelVersion 1.1 (Just (Beta (Just 1) Nothing)))

My patch is partly me learning Haskell, and I don't think it's right so I haven't submitted a PR yet, but I wanted to get clarification about the desired output from this structure. I should add, as an alternative we could make script/copy-models just ignore anything that doesn't match the supported format, this may make it easier going forward to maintain as there appears to be no written standard for the Go project with respect to directory hierarchy and naming... ):