Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ The team welcomes contributions! To make changes:

### Prerequisites

The generator is written in Java, so you'll need Java 8 installed on your machine. (We recommend [Intellij IDEA Community Edition](https://www.jetbrains.com/idea/) for Java projects.)
- Java 8
- Python2 (On macOS: `brew install python3`)
- Python3 (On macOS: `brew install python`)
- [pipenv](https://github.com/pypa/pipenv) (`pip3 install pipenv`)


_We recommend the free [VSCode](https://code.visualstudio.com/) editor to work on python projects
and [Intellij IDEA Community Edition](https://www.jetbrains.com/idea/) for Java projects._

### One-time setup for development

1. Fork the repository
1. Generate the IDE configuration: `./gradlew idea`
1. Open projects in Intellij: `open *.ipr`
1. Generate integration test bindings: `./gradlew generateVerifierBindings`
1. In `conjure-python-verification/python` create the virtual environment `PIPENV_VENV_IN_PROJECT=1 pipenv --python 3 shell`
1. In `conjure-python-verification/python` install all dependencies `pipenv install --dev`

### Development tips

- run `./gradlew checkstyleMain checkstyleTest` locally to make sure your code conforms to the code-style.
- Use `tox` in `conjure-python-verification/python` to run all tests using both python 2 and 3

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ conjure-python generates code that works on both Python 2 and Python 3.

## Generated services

- [TestService](./conjure-python-core/src/test/resources/services/expected/package/another/__init__.py)
- [TestService](./conjure-python-core/src/test/resources/services/expected/package/another/TestService.py)

```python
from httpremoting import RequestsClient, ServiceConfiguration
from conjure_python_client import RequestsClient, ServiceConfiguration

config = ServiceConfiguration()
config.uris = ["https://foo.com/api"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private PythonFile buildPythonSetupFile() {
.putOptions("name", config.packageName())
.putOptions("version", config.packageVersion())
.addInstallDependencies("requests", "typing")
.addInstallDependencies(String.format("conjure-client>=%s,<%s",
.addInstallDependencies(String.format("conjure-python-client>=%s,<%s",
config.minConjureClientVersion(), config.maxConjureClientVersion()));
config.packageDescription().ifPresent(value -> builder.putOptions("description", value));
config.packageUrl().ifPresent(value -> builder.putOptions("url", value));
Expand All @@ -163,7 +163,7 @@ private PythonFile buildCondaMetaYamlFile() {
.condaPackageName(config.packageName())
.packageVersion(config.packageVersion())
.addInstallDependencies("requests", "typing")
.addInstallDependencies(String.format("conjure-client >=%s,<%s",
.addInstallDependencies(String.format("conjure--python-client >=%s,<%s",
config.minConjureClientVersion(), config.maxConjureClientVersion()))
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
public interface PythonBean extends PythonClass {

ImmutableSet<PythonImport> DEFAULT_IMPORTS = ImmutableSet.of(
PythonImport.of(PythonClassName.of("conjure", "ConjureBeanType")),
PythonImport.of(PythonClassName.of("conjure", "ConjureFieldDefinition")));
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureBeanType")),
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureFieldDefinition")));

@Override
@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public interface PythonEnum extends PythonClass {

ImmutableSet<PythonImport> DEFAULT_IMPORTS = ImmutableSet.of(
PythonImport.of(PythonClassName.of("conjure", "ConjureEnumType")));
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureEnumType")));

@Override
@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
public interface PythonService extends PythonClass {

ImmutableSet<PythonImport> DEFAULT_IMPORTS = ImmutableSet.of(
PythonImport.of(PythonClassName.of("conjure", "ConjureEncoder")),
PythonImport.of(PythonClassName.of("conjure", "ConjureDecoder")),
PythonImport.of(PythonClassName.of("httpremoting", "Service")));
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureEncoder")),
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureDecoder")),
PythonImport.of(PythonClassName.of("conjure_python_client", "Service")));

@Override
@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public interface PythonUnionTypeDefinition extends PythonClass {

ImmutableSet<PythonImport> DEFAULT_IMPORTS = ImmutableSet.of(
PythonImport.of(PythonClassName.of("conjure", "ConjureUnionType")),
PythonImport.of(PythonClassName.of("conjure", "ConjureFieldDefinition")));
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureUnionType")),
PythonImport.of(PythonClassName.of("conjure_python_client", "ConjureFieldDefinition")));

@Override
@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Set<PythonImport> visitPrimitive(PrimitiveType value) {
if (value.equals(PrimitiveType.ANY)) {
return ImmutableSet.of(PythonImport.of(PythonClassName.of("typing", "Any")));
} else if (value.equals(PrimitiveType.BINARY)) {
return ImmutableSet.of(PythonImport.of(PythonClassName.of("conjure", "BinaryType")));
return ImmutableSet.of(PythonImport.of(PythonClassName.of("conjure_python_client", "BinaryType")));
}
return Collections.emptySet();
}
Expand All @@ -51,7 +51,7 @@ public Set<PythonImport> visitOptional(OptionalType value) {
ImmutableSet.Builder<PythonImport> setBuilder = ImmutableSet.builder();
return setBuilder
.add(PythonImport.of(PythonClassName.of("typing", "Optional")))
.add(PythonImport.of(PythonClassName.of("conjure", "OptionalType")))
.add(PythonImport.of(PythonClassName.of("conjure_python_client", "OptionalType")))
.addAll(value.getItemType().accept(this))
.build();
}
Expand All @@ -61,7 +61,7 @@ public Set<PythonImport> visitList(ListType value) {
ImmutableSet.Builder<PythonImport> setBuilder = ImmutableSet.builder();
return setBuilder
.add(PythonImport.of(PythonClassName.of("typing", "List")))
.add(PythonImport.of(PythonClassName.of("conjure", "ListType")))
.add(PythonImport.of(PythonClassName.of("conjure_python_client", "ListType")))
.addAll(value.getItemType().accept(this))
.build();
}
Expand All @@ -71,7 +71,7 @@ public Set<PythonImport> visitSet(SetType value) {
ImmutableSet.Builder<PythonImport> setBuilder = ImmutableSet.builder();
return setBuilder
.add(PythonImport.of(PythonClassName.of("typing", "Set")))
.add(PythonImport.of(PythonClassName.of("conjure", "ListType")))
.add(PythonImport.of(PythonClassName.of("conjure_python_client", "ListType")))
.addAll(value.getItemType().accept(this))
.build();
}
Expand All @@ -81,7 +81,7 @@ public Set<PythonImport> visitMap(MapType value) {
ImmutableSet.Builder<PythonImport> setBuilder = ImmutableSet.builder();
return setBuilder
.add(PythonImport.of(PythonClassName.of("typing", "Dict")))
.add(PythonImport.of(PythonClassName.of("conjure", "DictType")))
.add(PythonImport.of(PythonClassName.of("conjure_python_client", "DictType")))
.addAll(value.getKeyType().accept(this))
.addAll(value.getValueType().accept(this))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ConjurePythonGeneratorTest {
.packageName("package")
.packageVersion("0.0.0")
.packageDescription("project description")
.minConjureClientVersion("0.0.0")
.minConjureClientVersion("1.0.0")
.shouldWriteCondaRecipe(true)
.build());
private final InMemoryPythonFileWriter pythonFileWriter = new InMemoryPythonFileWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ requirements:
- setuptools
- requests
- typing
- conjure-client >=0.0.0,<1
- conjure--python-client >=1.0.0,<2

run:
- python
- requests
- typing
- conjure-client >=0.0.0,<1
- conjure--python-client >=1.0.0,<2
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from ..product.CreateDatasetRequest import CreateDatasetRequest
from ..product_datasets.BackingFileSystem import BackingFileSystem
from ..product_datasets.Dataset import Dataset
from conjure import BinaryType
from conjure import ConjureDecoder
from conjure import ConjureEncoder
from conjure import DictType
from conjure import ListType
from conjure import OptionalType
from httpremoting import Service
from conjure_python_client import BinaryType
from conjure_python_client import ConjureDecoder
from conjure_python_client import ConjureEncoder
from conjure_python_client import DictType
from conjure_python_client import ListType
from conjure_python_client import OptionalType
from conjure_python_client import Service
from typing import Dict
from typing import Optional
from typing import Set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class CreateDatasetRequest(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure import DictType
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition
from conjure_python_client import DictType
from typing import Dict

class BackingFileSystem(ConjureBeanType):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class Dataset(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
install_requires=[
'requests',
'typing',
'conjure-client>=0.0.0,<1',
'conjure-python-client>=1.0.0,<2',
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ requirements:
- setuptools
- requests
- typing
- conjure-client >=0.0.0,<1
- conjure--python-client >=1.0.0,<2

run:
- python
- requests
- typing
- conjure-client >=0.0.0,<1
- conjure--python-client >=1.0.0,<2
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from ..product.CreateDatasetRequest import CreateDatasetRequest
from ..product_datasets.BackingFileSystem import BackingFileSystem
from ..product_datasets.Dataset import Dataset
from conjure import BinaryType
from conjure import ConjureDecoder
from conjure import ConjureEncoder
from conjure import DictType
from conjure import ListType
from conjure import OptionalType
from httpremoting import Service
from conjure_python_client import BinaryType
from conjure_python_client import ConjureDecoder
from conjure_python_client import ConjureEncoder
from conjure_python_client import DictType
from conjure_python_client import ListType
from conjure_python_client import OptionalType
from conjure_python_client import Service
from typing import Dict
from typing import Optional
from typing import Set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import ConjureDecoder
from conjure import ConjureEncoder
from httpremoting import Service
from conjure_python_client import ConjureDecoder
from conjure_python_client import ConjureEncoder
from conjure_python_client import Service

class DeeplyNestedService(Service):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import ConjureDecoder
from conjure import ConjureEncoder
from httpremoting import Service
from conjure_python_client import ConjureDecoder
from conjure_python_client import ConjureEncoder
from conjure_python_client import Service

class SimpleNestedService(Service):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class SimpleObject(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import ConjureDecoder
from conjure import ConjureEncoder
from httpremoting import Service
from conjure_python_client import ConjureDecoder
from conjure_python_client import ConjureEncoder
from conjure_python_client import Service

class SimpleNestedService2(Service):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from .SafeLongAliasExample import SafeLongAliasExample
from .StringAliasExample import StringAliasExample
from .UuidAliasExample import UuidAliasExample
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure import DictType
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition
from conjure_python_client import DictType
from typing import Dict

class AliasAsMapKeyExample(ConjureBeanType):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition
from typing import Any

class AnyExample(ConjureBeanType):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure import DictType
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition
from conjure_python_client import DictType
from typing import Any
from typing import Dict

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class BearerTokenExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conjure import BinaryType
from conjure_python_client import BinaryType

BinaryAliasExample = BinaryType()

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conjure import BinaryType
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import BinaryType
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class BinaryExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class BooleanExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class CreateDatasetRequest(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class DateTimeExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class DoubleExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conjure import ConjureBeanType
from conjure import ConjureFieldDefinition
from conjure_python_client import ConjureBeanType
from conjure_python_client import ConjureFieldDefinition

class EmptyObjectExample(ConjureBeanType):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conjure import ConjureEnumType
from conjure_python_client import ConjureEnumType

class EnumExample(ConjureEnumType):
"""This enumerates the numbers 1:2."""
Expand Down
Loading