Skip to content

Commit

Permalink
Fix clobbered connector-builder-server directories (#19273)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifnada authored Nov 10, 2022
1 parent 125f35f commit 3421c7e
Show file tree
Hide file tree
Showing 40 changed files with 65 additions and 524 deletions.
2 changes: 1 addition & 1 deletion airbyte-connector-builder-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.coverage
.venv
state_*.yaml
state_*.yaml
21 changes: 0 additions & 21 deletions airbyte-connector-builder-server/LICENSE

This file was deleted.

30 changes: 29 additions & 1 deletion airbyte-connector-builder-server/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# Connector builder
# Connector builder


## Getting started

Set up the virtual environment and install dependencies
```bash
python -m venv .venv
source .venv/bin/activate
pip install .
```

Then run the server
```bash
uvicorn connector_builder.entrypoint:app --host 0.0.0.0 --port 8080
```

The server is now reachable on localhost:8080

### OpenAPI generation

```bash
openapi-generator generate -i ../connector-builder-server/src/main/openapi/openapi.yaml -g python-fastapi -c openapi/generator_config.yaml -o build/server -t openapi/templates
```

Or you can run it via Gradle by running this from the Airbyte project root:
```bash
./gradlew :airbyte-connector-builder-server:generateOpenApiPythonServer
```
34 changes: 27 additions & 7 deletions airbyte-connector-builder-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,36 @@ airbytePython {
moduleDirectory 'connector_builder'
}

task generateOpenApiPythonServer(type: GenerateTask){
outputs.upToDateWhen { false }

task generateApiServer(type: GenerateTask) {
def generatedCodeDir = "$buildDir/server"
inputSpec = "$rootDir.absolutePath/airbyte-connector-builder-server/src/main/openapi/openapi.yaml"
outputDir = "$buildDir/airbyte_connector_builder_server"

generatorName = "python"
packageName = "airbyte_connector_builder_server"
generatorName = "python-fastapi"
configFile = "$projectDir/openapi/generator_config.yaml"
templateDir = "$projectDir/openapi/templates"
packageName = "connector_builder.generated"

// After we generate, we're only interested in the API declaration and the generated pydantic models.
// So we copy those from the build/ directory
doLast {
def sourceDir = "$generatedCodeDir/src/connector_builder/generated/"
def targetDir = "$projectDir/connector_builder/generated"
mkdir targetDir
copy {
from "$sourceDir/apis"
include "*_interface.py", "__init__.py"
into "$targetDir/apis"
}
copy {
from "$sourceDir/models"
include "*.py"
into "$targetDir/models"
}
}
}

blackFormat.dependsOn generateApiServer
isortFormat.dependsOn generateApiServer
flakeCheck.dependsOn generateApiServer
installReqs.dependsOn generateApiServer
project.build.dependsOn(generateOpenApiPythonServer)

29 changes: 7 additions & 22 deletions airbyte-connector-builder-server/connector_builder/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

from typing import Union

from connector_builder.generated.apis.default_api_interface import initialize_router
from connector_builder.impl.default_api import DefaultApiImpl
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

origins = ["*"]

app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
app = FastAPI(
title="Connector Builder Server API",
description="Connector Builder Server API ",
version="1.0.0",
)


@app.get("/")
def read_root():
return {"Hello": "fastapi"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
app.include_router(initialize_router(DefaultApiImpl()))
File renamed without changes.
1 change: 0 additions & 1 deletion airbyte-connector-builder-server/run.sh

This file was deleted.

17 changes: 1 addition & 16 deletions airbyte-connector-builder-server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,9 @@
},
packages=find_packages(exclude=("unit_tests", "integration_tests", "docs")),
package_data={},
install_requires=[
"click~=8.0.3",
"fastapi>=0.68.0,<0.69.0",
"pydantic>=1.8.0,<2.0.0",
"uvicorn>=0.15.0,<0.16.0",
# f"airbyte_connector_builder @ file://{os.getcwd()}/build/airbyte_connector_builder", # FIXME: This should point to the server interface generated by the openAPI generator
"jinja2~=3.0.3",
"deepdiff~=5.7.0",
"pyyaml~=6.0",
"analytics-python~=1.4.0",
"python-slugify~=6.1.2",
],
install_requires=["fastapi", "uvicorn"],
python_requires=">=3.9.11",
extras_require={
"tests": ["MyPy~=0.812", "pytest~=6.2.5", "pytest-cov", "pytest-mock", "pytest-recording", "requests-mock", "pre-commit"],
"sphinx-docs": [
"Sphinx~=4.2",
"sphinx-rtd-theme~=1.0",
],
},
)
3 changes: 0 additions & 3 deletions airbyte-connector-builder/.coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions airbyte-connector-builder/.dockerignore

This file was deleted.

3 changes: 0 additions & 3 deletions airbyte-connector-builder/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion airbyte-connector-builder/.python-version

This file was deleted.

Empty file.
15 changes: 0 additions & 15 deletions airbyte-connector-builder/Dockerfile

This file was deleted.

29 changes: 0 additions & 29 deletions airbyte-connector-builder/README.md

This file was deleted.

45 changes: 0 additions & 45 deletions airbyte-connector-builder/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions airbyte-connector-builder/connector_builder/__init__.py

This file was deleted.

15 changes: 0 additions & 15 deletions airbyte-connector-builder/connector_builder/entrypoint.py

This file was deleted.

7 changes: 0 additions & 7 deletions airbyte-connector-builder/pytest.ini

This file was deleted.

49 changes: 0 additions & 49 deletions airbyte-connector-builder/setup.py

This file was deleted.

Loading

0 comments on commit 3421c7e

Please sign in to comment.