-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #361 from datayoga-io/360-build-connections-jsonsc…
…hema-and-use-it-in-schemastore-catalog build connections schema and rename to `connections.dy.yaml`
- Loading branch information
Showing
31 changed files
with
1,216 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Generate JSON Schema | ||
name: Generate JSON Schemas | ||
|
||
on: | ||
workflow_dispatch: | ||
|
@@ -36,9 +36,10 @@ jobs: | |
poetry build | ||
pip install dist/*.whl | ||
- name: Generate DataYoga Job Schema | ||
- name: Generate DataYoga Job and Connections Schemas | ||
run: | | ||
python -c "import json; from datayoga_core.job import Job; schema = Job.get_json_schema(); open('schemas/job.schema.json', 'w').write(json.dumps(schema))" | ||
python -c "import json; from datayoga_core.connection import Connection; schema = Connection.get_json_schema(); open('schemas/coonnections.schema.json', 'w').write(json.dumps(schema))" | ||
- name: Prettify JSON Schema files | ||
run: prettier --write "schemas/**/*.json" | ||
|
@@ -47,6 +48,7 @@ jobs: | |
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git pull | ||
git add . | ||
if ! git diff --cached --exit-code; then | ||
git commit -m "update json schemas" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import Any, Dict | ||
|
||
from datayoga_core import utils | ||
from datayoga_core.context import Context | ||
|
||
|
||
class Connection: | ||
"""Connection""" | ||
|
||
@staticmethod | ||
def get_connection_details(connection_name: str, context: Context) -> Dict[str, Any]: | ||
"""Gets connection details from the context""" | ||
if context and context.properties: | ||
connection = context.properties.get("connections", {}).get(connection_name) | ||
if connection: | ||
return connection | ||
|
||
raise ValueError(f"{connection_name} connection not found") | ||
|
||
@staticmethod | ||
def get_json_schema() -> Dict[str, Any]: | ||
"""Compiles a complete JSON schema of the connection with all possible types""" | ||
connection_schemas = [] | ||
|
||
connections_dir = utils.get_resource_path(os.path.join("schemas", "connections")) | ||
|
||
for schema_path in sorted(Path(connections_dir).rglob("**/*.schema.json"), key=lambda p: p.stem): | ||
connection_schemas.append(utils.read_json(f"{schema_path}")) | ||
|
||
connections_general_schema = utils.read_json( | ||
os.path.join( | ||
utils.get_bundled_dir() if utils.is_bundled() else os.path.dirname(os.path.realpath(__file__)), | ||
"resources", "schemas", "connections.schema.json")) | ||
|
||
connections_general_schema["definitions"]["connection"]["oneOf"] = connection_schemas | ||
|
||
return connections_general_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.