Skip to content

Valid conjure definition results in circular python import #62

Open
@ahggns

Description

@ahggns

What happened?

I modified the https://github.com/palantir/conjure-java-example to introduce a circular dependency between packages:

--- a/recipe-example-api/src/main/conjure/recipe-example-api.yml
+++ b/recipe-example-api/src/main/conjure/recipe-example-api.yml
@@ -14,6 +14,7 @@ types:
         alias: string

       BakeStep:
+        package: com.palantir.conjure.examples.recipe.api.step
         fields:
           temperature: Temperature
           durationInSeconds: integer

This causes two python packages to be created (expected):
conjure_examples_recipe_api:

from ..conjure_examples_recipe_api_step import BakeStep
from abc import ABCMeta, abstractmethod
from conjure_python_client import ConjureBeanType, ConjureDecoder, ConjureEncoder, ConjureEnumType, ConjureFieldDefinition, ConjureUnionType, ListType, Service
from typing import List, Set

class Recipe(ConjureBeanType):
[...]

conjure_examples_recipe_api_step:

from ..conjure_examples_recipe_api import Temperature
from conjure_python_client import ConjureBeanType, ConjureFieldDefinition

class BakeStep(ConjureBeanType):
[...]

This python code cannot be imported due to the circular dependency:

>>> import sys
>>> sys.path.append("/src/ahiggins/conjure-java-example/recipe-example-api/recipe-example-api-python/python/")
>>> from recipe_example_api.conjure_examples_recipe_api import Temperature

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-428f65a0c05a> in <module>
      1 import sys, os
      2 sys.path.append("/src/ahiggins/conjure-java-example/recipe-example-api/recipe-example-api-python/python/")
----> 3 from recipe_example_api.conjure_examples_recipe_api import Temperature

/src/ahiggins/conjure-java-example/recipe-example-api/recipe-example-api-python/python/recipe_example_api/conjure_examples_recipe_api/__init__.py in <module>
----> 1 from ..conjure_examples_recipe_api_step import BakeStep
      2 from abc import ABCMeta, abstractmethod
      3 from conjure_python_client import ConjureBeanType, ConjureDecoder, ConjureEncoder, ConjureEnumType, ConjureFieldDefinition, ConjureUnionType, ListType, Service
      4 from typing import List, Set
      5 

/src/ahiggins/conjure-java-example/recipe-example-api/recipe-example-api-python/python/recipe_example_api/conjure_examples_recipe_api_step/__init__.py in <module>
----> 1 from ..conjure_examples_recipe_api import Temperature
      2 from conjure_python_client import ConjureBeanType, ConjureFieldDefinition
      3 
      4 class BakeStep(ConjureBeanType):
      5 

ImportError: cannot import name 'Temperature'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions