Skip to content

Commit ddd6a7f

Browse files
committed
testing changes to streams
1 parent 160e35e commit ddd6a7f

File tree

7 files changed

+79
-101
lines changed

7 files changed

+79
-101
lines changed

airbyte-integrations/connectors/source-medrio/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7.11-alpine3.14 as base
1+
FROM python:3.9.11-alpine3.15 as base
22

33
# build and load all requirements
44
FROM base as builder
@@ -40,5 +40,5 @@ COPY source_medrio ./source_medrio
4040
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
4141
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
4242

43-
LABEL io.airbyte.version=0.1.0
43+
LABEL io.airbyte.version=0.1.1
4444
LABEL io.airbyte.name=airbyte/source-medrio

airbyte-integrations/connectors/source-medrio/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ build : login
88
@echo image=${IMG}
99
@docker buildx build . \
1010
--platform "linux/amd64,linux/arm64" \
11-
--tag ${LATEST} \
11+
--tag ${IMG} \
1212
--push
1313
@docker buildx build . \
1414
--platform "linux/arm64" \
15-
--tag ${LATEST} \
15+
--tag ${IMG} \
1616
--load
1717

1818
dev : login
1919
@echo image=${IMG}
2020
@docker buildx build . \
2121
--platform "linux/amd64,linux/arm64" \
22+
--tag ${IMG} \
2223
--tag ${DEV} \
2324
--push
2425
@docker buildx build . \
2526
--platform "linux/arm64" \
27+
--tag ${IMG} \
2628
--tag ${DEV} \
2729
--load
2830

airbyte-integrations/connectors/source-medrio/README.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ To build using Gradle, from the Airbyte repository root, run:
4040

4141
#### Create credentials
4242
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/medrio-dataviews)
43-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_medrio_dataviews/spec.json` file.
43+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_medrio/spec.json` file.
4444
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
4545
See `integration_tests/sample_config.json` for a sample config file.
4646

@@ -65,16 +65,6 @@ docker buildx build . \
6565
--tag 878324840923.dkr.ecr.us-east-1.amazonaws.com/airbyte/source-medrio:dev \
6666
--push &
6767
68-
docker buildx build . \
69-
--platform "linux/amd64" \
70-
--tag 878324840923.dkr.ecr.us-east-1.amazonaws.com/airbyte/source-medrio:dev-amd \
71-
--push &
72-
73-
docker buildx build . \
74-
--platform "linux/arm64" \
75-
--tag 878324840923.dkr.ecr.us-east-1.amazonaws.com/airbyte/source-medrio:dev-arm \
76-
--push &
77-
7868
docker buildx build . \
7969
--platform "linux/arm64" \
8070
--tag 878324840923.dkr.ecr.us-east-1.amazonaws.com/airbyte/source-medrio:dev \

airbyte-integrations/connectors/source-medrio/source_medrio/source.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from airbyte_cdk.sources.streams import Stream
1010
from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator
1111
from requests.api import request
12-
from .medrio_odm import MedrioOdmApi, MedrioOdmXml
13-
from .streams import ApprovalEvent, FormStatus, Studies, Queries, MedrioOdm
12+
from .medrio_odm import MedrioOdmApi
13+
from .streams import ApprovalEvent, FormStatus, Studies, Queries
1414

1515
logger = AirbyteLogger()
1616

@@ -44,9 +44,7 @@ def get_token(self, config, api_version: str) -> TokenAuthenticator:
4444
if api_version in auth_urls:
4545
request_url, grant_type = auth_urls.get(api_version)
4646
else:
47-
raise KeyError(
48-
f"api_version {api_version} not one of {list(auth_urls.keys())}"
49-
)
47+
raise KeyError(f"api_version {api_version} not one of {list(auth_urls.keys())}")
5048
headers = {"Content-Type": "application/x-www-form-urlencoded"}
5149
data = {
5250
"username": config["api_user_name"],
@@ -61,9 +59,7 @@ def get_token(self, config, api_version: str) -> TokenAuthenticator:
6159
else:
6260
raise RuntimeError(response.json().get("message"))
6361

64-
def discover(
65-
self, logger: AirbyteLogger, config: Mapping[str, Any]
66-
) -> AirbyteCatalog:
62+
def discover(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteCatalog:
6763
return super().discover(logger, config)
6864

6965
def read(
@@ -81,10 +77,10 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
8177
odm_api = MedrioOdmApi(api_key=config["enterprise_api_key"])
8278
studies = odm_api.get_studies()
8379
streams = []
84-
for study_name in config["medrio_study_name_array"]:
85-
stream = MedrioOdm(api=copy.deepcopy(odm_api), study_id=studies[study_name])
86-
stream.update_schema(extra_schema={}, stream_name=study_name)
87-
streams.append(stream)
80+
# for study_name in config["medrio_study_name_array"]:
81+
# stream = MedrioOdm(api=copy.deepcopy(odm_api), study_id=studies[study_name])
82+
# stream.update_schema(extra_schema={}, stream_name=study_name)
83+
# streams.append(stream)
8884
return streams + [
8985
Studies(authenticator=auth_v1),
9086
Queries(authenticator=auth_v2),

airbyte-integrations/connectors/source-medrio/source_medrio/spec.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"required": [
88
"api_user_name",
99
"api_user_password",
10-
"enterprise_api_key",
11-
"medrio_study_name_array"
10+
"enterprise_api_key"
1211
],
1312
"additionalProperties": false,
1413
"properties": {
@@ -28,7 +27,8 @@
2827
},
2928
"medrio_study_name_array": {
3029
"type": "array",
31-
"description": "Select Medrio studies to replicate by name."
30+
"description": "Select Medrio studies to replicate by name.",
31+
"default": []
3232
}
3333
}
3434
}

airbyte-integrations/connectors/source-medrio/source_medrio/streams.py

+58-68
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ def request_params(
6363
return params
6464

6565

66-
class MedrioV1Stream(MedrioHttpStream):
67-
def __init__(self, **kwargs):
68-
super().__init__(**kwargs)
69-
70-
def get_json_schema(self):
71-
schema = super().get_json_schema()
72-
schema["dynamically_determined_property"] = "property"
73-
return schema
74-
75-
7666
class MedrioV1Stream(MedrioHttpStream):
7767
def __init__(self, **kwargs):
7868
super().__init__(**kwargs)
@@ -202,61 +192,61 @@ def path(self, **kwargs) -> str:
202192
return "QueryReports"
203193

204194

205-
class ClinicalData(MedrioV2StreamIncremental):
206-
primary_key = "GlobalDatumId"
207-
208-
def __init__(self, api: MedrioOdmApi, study_id: str, **kwargs):
209-
self.api = api
210-
self.study_id = study_id
211-
super().__init__(**kwargs)
212-
213-
def get_json_schema(self):
214-
self.name = "odm_clinical" # change just to get shared json_schema
215-
schema = super().get_json_schema()
216-
schema["properties"].update(self.extra_schema)
217-
self.name = self.stream_name # change name back now that we've got schema
218-
return schema
219-
220-
221-
class DataAudit(MedrioV2StreamIncremental):
222-
primary_key = "GlobalDatumId"
223-
cursor_field = "DataEntryUtcDateVal"
224-
225-
def path(self, **kwargs) -> str:
226-
return "DataAuditReports"
227-
228-
229-
class MedrioOdm(Stream):
230-
primary_key = ["FormOID", "SubjectKey", "ItemGroupRepeatKey"]
231-
cursor_field = "DateTimeStamp"
232-
stream_name = None
233-
name = "odm_clinical"
234-
235-
def __init__(self, api: MedrioOdmApi, study_id: str, **kwargs):
236-
self.api = api
237-
self.study_id = study_id
238-
super().__init__(**kwargs)
239-
240-
def get_json_schema(self):
241-
self.name = "odm_clinical" # change just to get shared json_schema
242-
schema = super().get_json_schema()
243-
schema["properties"].update(self.extra_schema)
244-
self.name = self.stream_name # change name back now that we've got schema
245-
return schema
246-
247-
def update_schema(self, extra_schema: dict, stream_name: str):
248-
self.extra_schema = extra_schema
249-
self.name = stream_name # set the name of the schema
250-
self.stream_name = stream_name # capture extra param to keep name
251-
252-
def read_records(
253-
self,
254-
sync_mode: SyncMode,
255-
cursor_field: List[str] = None,
256-
stream_slice: Mapping[str, Any] = None,
257-
stream_state: Mapping[str, Any] = None,
258-
) -> Iterable[Mapping[str, Any]]:
259-
xml_string = self.api.main(content_type="AllData", study_id=self.study_id)
260-
odm_xml = MedrioOdmXml(xml_string)
261-
records = odm_xml.parse_clinical()
262-
return records
195+
# class ClinicalData(MedrioV2StreamIncremental):
196+
# primary_key = "GlobalDatumId"
197+
198+
# def __init__(self, api: MedrioOdmApi, study_id: str, **kwargs):
199+
# self.api = api
200+
# self.study_id = study_id
201+
# super().__init__(**kwargs)
202+
203+
# def get_json_schema(self):
204+
# self.name = "odm_clinical" # change just to get shared json_schema
205+
# schema = super().get_json_schema()
206+
# schema["properties"].update(self.extra_schema)
207+
# self.name = self.stream_name # change name back now that we've got schema
208+
# return schema
209+
210+
211+
# class DataAudit(MedrioV2StreamIncremental):
212+
# primary_key = "GlobalDatumId"
213+
# cursor_field = "DataEntryUtcDateVal"
214+
215+
# def path(self, **kwargs) -> str:
216+
# return "DataAuditReports"
217+
218+
219+
# class MedrioOdm(Stream):
220+
# primary_key = ["FormOID", "SubjectKey", "ItemGroupRepeatKey"]
221+
# cursor_field = "DateTimeStamp"
222+
# stream_name = None
223+
# name = "odm_clinical"
224+
225+
# def __init__(self, api: MedrioOdmApi, study_id: str, **kwargs):
226+
# self.api = api
227+
# self.study_id = study_id
228+
# super().__init__(**kwargs)
229+
230+
# def get_json_schema(self):
231+
# self.name = "odm_clinical" # change just to get shared json_schema
232+
# schema = super().get_json_schema()
233+
# schema["properties"].update(self.extra_schema)
234+
# self.name = self.stream_name # change name back now that we've got schema
235+
# return schema
236+
237+
# def update_schema(self, extra_schema: dict, stream_name: str):
238+
# self.extra_schema = extra_schema
239+
# self.name = stream_name # set the name of the schema
240+
# self.stream_name = stream_name # capture extra param to keep name
241+
242+
# def read_records(
243+
# self,
244+
# sync_mode: SyncMode,
245+
# cursor_field: List[str] = None,
246+
# stream_slice: Mapping[str, Any] = None,
247+
# stream_state: Mapping[str, Any] = None,
248+
# ) -> Iterable[Mapping[str, Any]]:
249+
# xml_string = self.api.main(content_type="AllData", study_id=self.study_id)
250+
# odm_xml = MedrioOdmXml(xml_string)
251+
# records = odm_xml.parse_clinical()
252+
# return records

airbyte-integrations/connectors/source-medrio/unit_tests/test_source.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
from unittest.mock import MagicMock
66

7-
from source_medrio.source import SourceMedrioDataviews
7+
from source_medrio.source import SourceMedrio
88

99

1010
def test_check_connection(mocker):
11-
source = SourceMedrioDataviews()
11+
source = SourceMedrio()
1212
logger_mock, config_mock = MagicMock(), MagicMock()
1313
assert source.check_connection(logger_mock, config_mock) == (True, None)
1414

1515

1616
def test_streams(mocker):
17-
source = SourceMedrioDataviews()
17+
source = SourceMedrio()
1818
config_mock = MagicMock()
1919
streams = source.streams(config_mock)
2020
# TODO: replace this with your streams number

0 commit comments

Comments
 (0)