id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
27,627 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | Fetch the conversion window from the config and error on invalid values |
27,628 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,629 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,630 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,631 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,632 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,633 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,634 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | This function lets us know that backoff ran, but it does not print Google's verbose message and stack trace |
27,635 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,636 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | The proto field name for `type` is `type_` which will get stripped by the Transformer. So we replace all instances of the key `"type_"` before `json.loads`ing it |
27,637 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,638 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,639 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | Return a date within the conversion window and after start date All inputs are datetime strings. NOTE: `bookmark` may be None |
27,640 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,641 | import hashlib
import json
from collections import defaultdict
from datetime import timedelta
import backoff
import singer
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.protobuf.json_format import MessageToJson
from requests.ex... | null |
27,642 | import requests
import base64
from singer import metrics, utils
import singer
LOGGER = singer.get_logger()
class ModeError(Exception):
pass
def get_exception_for_error_code(error_code, mode_error_code):
if mode_error_code == 'scroll_exists':
error_code = 423
return ERROR_CODE_EXCEPTION_MAPPING.get(e... | null |
27,643 | import os
import json
from mage_integrations.sources.mode.streams import STREAMS
from singer import metadata
def get_abs_path(path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)
The provided code snippet includes necessary dependencies for implementing the `get_schemas` function. Write a ... | Loads the schemas defined for the tap. This function iterates through the STREAMS dictionary which contains a mapping of the stream name and its corresponding class and loads the matching schema file from the schemas directory. |
27,644 | import requests
from singer import metrics, utils
import singer
LOGGER = singer.get_logger()
class IntercomError(Exception):
pass
def get_exception_for_error_code(error_code, intercom_error_code):
if intercom_error_code == 'scroll_exists':
error_code = 423
return ERROR_CODE_EXCEPTION_MAPPING.get(err... | null |
27,645 | import os
import json
from mage_integrations.sources.intercom.streams import STREAMS
from singer import metadata
def get_abs_path(path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)
The provided code snippet includes necessary dependencies for implementing the `get_schemas` function. Writ... | Loads the schemas defined for the tap. This function iterates through the STREAMS dictionary which contains a mapping of the stream name and its corresponding class and loads the matching schema file from the schemas directory. |
27,646 | import math as m
from singer.utils import strptime_to_utc
def denest_list_nodes(this_json, data_key, list_nodes):
new_json = this_json
i = 0
for record in list(this_json.get(data_key, [])):
for list_node in list_nodes:
this_node = record.get(list_node, {}).get(list_node, [])
... | null |
27,647 | import math as m
from singer.utils import strptime_to_utc
def find_datetimes_in_schema(schema):
paths = []
if 'properties' in schema and isinstance(schema, dict):
for k, v in schema['properties'].items(): #pylint: disable=invalid-name
if 'format' in v and v['format'] == 'date-time':
... | null |
27,648 | import math as m
from singer.utils import strptime_to_utc
def get_integer_places(value):
if 0 <= value <= 999999999999997:
return int(m.log10(value)) + 1
elif value < 0:
return 10
else:
counter = 15
while value >= 10**counter:
counter += 1
return counter
d... | null |
27,649 | from typing import Dict
from singer import utils
import requests
import singer
STATUS_CODE_EXCEPTION_MAPPING = {
400: {
"raise_exception": BadRequestError,
"message": "The request URI does not match the APIs in the system.",
},
401: {
"raise_exception": AuthenticationError,
"... | Raises error class with appropriate msg for the response |
27,650 | import singer
from singer.catalog import Catalog, CatalogEntry, Schema
from mage_integrations.sources.twitter_ads.tap_twitter_ads.schema import get_schemas
LOGGER = singer.get_logger()
def discover(reports, logger=LOGGER):
schemas, field_metadata = get_schemas(reports, logger=logger)
catalog = Catalog([])
... | null |
27,651 | import singer
from mage_integrations.sources.twitter_ads.tap_twitter_ads.streams import (
STREAMS,
Reports,
update_currently_syncing,
)
LOGGER = singer.get_logger()
def sync(client, config, catalog, state, logger=LOGGER):
# Get config parameters
account_list = config.get('account_ids').replace(' ',... | null |
27,652 | from singer import get_logger
ERROR_CODE_EXCEPTION_MAPPING = {
400: {
"raise_exception": TwitterAdsBadRequestError,
"message": "The request is missing or has a bad parameter."
},
401: {
"raise_exception": TwitterAdsUnauthorizedError,
"message": "Unauthorized access for the UR... | null |
27,653 | import json
import os
import singer
from singer import metadata
from mage_integrations.sources.twitter_ads.tap_twitter_ads.streams import STREAMS
LOGGER = singer.get_logger()
GRANULARITIES = [
'HOUR',
'DAY',
'TOTAL'
]
ENTITY_TYPES = [
'ACCOUNT',
'CAMPAIGN',
'FUNDING_INSTRUMENT',
'LINE_ITEM',... | null |
27,654 | import copy
import functools
import time
from datetime import datetime, timedelta
from urllib.parse import urlparse
import backoff
import pytz
import singer
from requests.exceptions import ConnectionError
from singer import Transformer, metadata, metrics, utils
from singer.utils import strptime_to_utc
from twitter_ads ... | null |
27,655 | import copy
import functools
import time
from datetime import datetime, timedelta
from urllib.parse import urlparse
import backoff
import pytz
import singer
from requests.exceptions import ConnectionError
from singer import Transformer, metadata, metrics, utils
from singer.utils import strptime_to_utc
from twitter_ads ... | This function will get page size from config. It will return the default value if an empty string is given, and will raise an exception if invalid value is given. |
27,656 | import copy
import functools
import time
from datetime import datetime, timedelta
from urllib.parse import urlparse
import backoff
import pytz
import singer
from requests.exceptions import ConnectionError
from singer import Transformer, metadata, metrics, utils
from singer.utils import strptime_to_utc
from twitter_ads ... | null |
27,657 | from datetime import timedelta
import json
import hashlib
import singer
from singer.utils import strptime_to_utc, strftime
LOGGER = singer.get_logger()
def hash_data(data):
# Prepare the project id hash
hash_id = hashlib.md5()
hash_id.update(repr(data).encode('utf-8'))
return hash_id.hexdigest()
def tr... | null |
27,658 | from datetime import timedelta
import json
import hashlib
import singer
from singer.utils import strptime_to_utc, strftime
def transform_record(stream_name, record):
new_record = record
return new_record | null |
27,659 | import inspect
import json
import os
from datetime import datetime, timedelta
import pytz
import singer
from dateutil.parser import parse
from mage_integrations.sources.chargebee.state import (
get_last_record_value_for_table,
incorporate,
)
from mage_integrations.sources.chargebee.streams.util import Util
from... | null |
27,660 | from singer import utils
import requests
import singer
STATUS_CODE_EXCEPTION_MAPPING = {
400: {
"raise_exception": ChargebeeBadRequestError,
"message": "The request URI does not match the APIs in the system.",
},
401: {
"raise_exception": ChargebeeAuthenticationError,
"messag... | Raises error class with appropriate msg for the response |
27,661 | import datetime
import singer
def get_last_record_value_for_table(state, table, field):
if state is None:
return None
last_value = state.get('bookmarks', {}) \
.get(table, {}) \
.get(field)
if last_value is None:
return None
return last_val... | null |
27,662 | import datetime
import singer
def incorporate(state, table, key, value, force=False):
if value is None:
return state
if isinstance(value, datetime.datetime):
value = value.strftime('%Y-%m-%dT%H:%M:%SZ')
if state is None:
new_state = {}
else:
new_state = state.copy()
... | null |
27,663 | from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import datetime, timezone, timedelta
import io
from typing import Tuple, Union, Optional, List
def convert_pg_ts(_ts_in_microseconds: int) -> datetime:
ts = datetime(2000, 1, 1, 0, 0, 0, 0, tzinfo=timezone.utc)
return ts + tim... | null |
27,664 | from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import datetime, timezone, timedelta
import io
from typing import Tuple, Union, Optional, List
def convert_bytes_to_int(_in_bytes: bytes) -> int:
return int.from_bytes(_in_bytes, byteorder='big', signed=True) | null |
27,665 | from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import datetime, timezone, timedelta
import io
from typing import Tuple, Union, Optional, List
def convert_bytes_to_utf8(_in_bytes: Union[bytes, bytearray]) -> str:
return (_in_bytes).decode('utf-8') | null |
27,666 | from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import datetime, timezone, timedelta
import io
from typing import Tuple, Union, Optional, List
class Begin(PgoutputMessage):
"""
https://pgpedia.info/x/xlogrecptr.html
https://www.postgresql.org/docs/14/datatype-pg-lsn.html
... | Peak first byte and initialise the appropriate message object |
27,667 | from operator import itemgetter
import json
import sys
import csv
def load_records():
for line in sys.stdin:
yield json.loads(line) | null |
27,668 | from operator import itemgetter
import json
import sys
import csv
def translate_breakdown(breakdown):
if breakdown is None:
return ''
if breakdown == ['age', 'gender']:
return 'ag'
if breakdown == ['country']:
return 'c'
if breakdown == ['placement', 'impression_device']:
... | null |
27,669 | from operator import itemgetter
import json
import sys
import csv
def success(rec):
return rec['success']
def proportion(pred, recs):
return float(len(list(filter(pred, recs)))) / float(len(recs))
def p_success(recs):
return proportion(success, recs) | null |
27,670 | from operator import itemgetter
import json
import sys
import csv
def p_breakdown(breakdown, recs):
return proportion(lambda r: r['bd'] == breakdown, recs)
def p_success_and_breakdown(breakdown, recs):
return proportion(lambda r: success(r) and r['bd'] == breakdown, recs)
def p_success_given_breakdown(breakdow... | null |
27,671 | from operator import itemgetter
import json
import sys
import csv
def p_nabd(nabd, recs):
return proportion(lambda r: r['nabd'] == nabd, recs)
def p_success_and_nabd(nabd, recs):
return proportion(lambda r: success(r) and r['nabd'] == nabd, recs)
def p_success_given_nabd(nabd, recs):
return p_success_and_n... | null |
27,672 | from operator import itemgetter
import json
import sys
import csv
def p_naaw(naaw, recs):
return proportion(lambda r: r['naaw'] == naaw, recs)
def p_success_and_naaw(naaw, recs):
return proportion(lambda r: success(r) and r['naaw'] == naaw, recs)
def p_success_given_naaw(naaw, recs):
denom = p_naaw(naaw, r... | null |
27,673 | from typing import Any, Callable, Dict, Union
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
COLUMN_TYPE_OBJECT,
)
from mage_integrations.sources.sql.constants import PredicateOperator
from... | null |
27,674 | from typing import Any, Callable, Dict, Union
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
COLUMN_TYPE_OBJECT,
)
from mage_integrations.sources.sql.constants import PredicateOperator
from... | null |
27,675 | from typing import Any, Callable, Dict, Union
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
COLUMN_TYPE_OBJECT,
)
from mage_integrations.sources.sql.constants import PredicateOperator
from... | null |
27,676 | from typing import Any, Callable, Dict, Union
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
COLUMN_TYPE_OBJECT,
)
from mage_integrations.sources.sql.constants import PredicateOperator
from... | null |
27,677 | from mage_integrations.utils.parsers import encode_complex
from singer.messages import (
RecordMessage,
SchemaMessage as SchemaMessageOriginal,
StateMessage,
)
from typing import List
import simplejson
import sys
class SchemaMessage(SchemaMessageOriginal):
def __init__(
self,
disable_col... | Write a schema message. stream = 'test' schema = {'properties': {'id': {'type': 'integer'}, 'email': {'type': 'string'}}} # nopep8 key_properties = ['id'] write_schema(stream, schema, key_properties) |
27,678 | from mage_integrations.utils.parsers import encode_complex
from singer.messages import (
RecordMessage,
SchemaMessage as SchemaMessageOriginal,
StateMessage,
)
from typing import List
import simplejson
import sys
def write_record(stream_name, record, stream_alias=None, time_extracted=None):
"""Write a s... | Write a list of records for the given stream. chris = {"id": 1, "email": "chris@stitchdata.com"} mike = {"id": 2, "email": "mike@stitchdata.com"} write_records("users", [chris, mike]) |
27,679 | from mage_integrations.utils.parsers import encode_complex
from singer.messages import (
RecordMessage,
SchemaMessage as SchemaMessageOriginal,
StateMessage,
)
from typing import List
import simplejson
import sys
def write_message(message):
sys.stdout.write(format_message(message) + '\n')
sys.stdout... | Write a state message. write_state({'last_updated_at': '2017-02-14T09:21:00'}) |
27,680 | from mage_integrations.sources.constants import (
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NUMBER,
COLUMN_TYPE_OBJECT,
)
from mage_integrations.sources.redshift.constants import (
DATA_TYPE_BOOLEAN,
DATA_TYPE_BIGINT,
DATA_TYPE_DOUBLE_PRECISION,
DATA_TYPE_TEXT,
DATA_TYPE_... | null |
27,681 | import os
import json
import singer
from singer import metadata
from .sync import STREAM_CONFIGS
from singer.catalog import Schema
from mage_integrations.sources.catalog import Catalog, CatalogEntry
def get_schemas():
schemas = {}
schemas_metadata = {}
schemas_path = get_abs_path('schemas')
file_names =... | null |
27,682 | import singer
from singer import metrics, metadata, Transformer
from singer.bookmarks import set_currently_syncing
from mage_integrations.sources.messages import write_schema as write_schema_orig
from datetime import datetime, timedelta
import dateutil.parser
LOGGER = singer.get_logger()
def sync_endpoint(client, confi... | null |
27,683 | from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
)
from mage_integrations.utils.array import find
from typing import Any, Callable, Dict
def column_func(column_type: str) -> str:
if COLUMN_TY... | null |
27,684 | from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLUMN_TYPE_INTEGER,
COLUMN_TYPE_NULL,
COLUMN_TYPE_NUMBER,
)
from mage_integrations.utils.array import find
from typing import Any, Callable, Dict
def wrap_column_in_quotes(column):
if "`" not in colu... | null |
27,685 | import requests
from singer import metrics, utils
class PowerbiError(Exception):
def get_exception_for_error_code(error_code, powerbi_error_code):
def raise_for_error(response, logger):
try:
response.raise_for_status()
except (requests.HTTPError, requests.ConnectionError) as error:
try:
... | null |
27,686 | import json
import os
from singer import metadata
from mage_integrations.sources.powerbi.streams import STREAMS
def get_abs_path(path):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)
The provided code snippet includes necessary dependencies for implementing the `get_schemas` function. Write... | Loads the schemas defined for the tap. This function iterates through the STREAMS dictionary which contains a mapping of the stream name and its corresponding class and loads the matching schema file from the schemas directory. |
27,687 | import math
import json
from datetime import datetime, timedelta
import pytz
import singer
from singer.utils import strftime
def transform_sheet_metadata(spreadsheet_id, sheet, columns):
# Convert to properties to dict
sheet_metadata = sheet.get('properties')
sheet_metadata_tf = json.loads(json.dumps(sheet... | null |
27,688 | import math
import json
from datetime import datetime, timedelta
import pytz
import singer
from singer.utils import strftime
def transform_spreadsheet_metadata(spreadsheet_metadata):
# Convert to dict
spreadsheet_metadata_tf = json.loads(json.dumps(spreadsheet_metadata))
# Remove keys: defaultFormat and sh... | null |
27,689 | import math
import json
from datetime import datetime, timedelta
import pytz
import singer
from singer.utils import strftime
def transform_file_metadata(file_metadata):
# Convert to dict
file_metadata_tf = json.loads(json.dumps(file_metadata))
# Remove keys
if file_metadata_tf.get('lastModifyingUser'):... | null |
27,690 | import math
import json
from datetime import datetime, timedelta
import pytz
import singer
from singer.utils import strftime
LOGGER = singer.get_logger()
def get_column_value(value, unformatted_value, sheet_title, col_name, col_letter, row_num, col_type, row):
# NULL values
if value is None or value == '':
... | null |
27,691 | from mage_integrations.utils.dictionary import extract
from typing import Dict
SYSTEM_QUERY_END_DATE = '_end_date'
def get_end_date(query: Dict) -> Dict:
return query.get(SYSTEM_QUERY_END_DATE) | null |
27,692 | from mage_integrations.utils.dictionary import extract
from typing import Dict
SYSTEM_QUERY_EXECUTION_DATE = '_execution_date'
def get_execution_date(query: Dict) -> Dict:
return query.get(SYSTEM_QUERY_EXECUTION_DATE) | null |
27,693 | from mage_integrations.utils.dictionary import extract
from typing import Dict
SYSTEM_QUERY_EXECUTION_PARTITION = '_execution_partition'
def get_execution_partition(query: Dict) -> Dict:
return query.get(SYSTEM_QUERY_EXECUTION_PARTITION) | null |
27,694 | from mage_integrations.utils.dictionary import extract
from typing import Dict
SYSTEM_QUERY_START_DATE = '_start_date'
def get_start_date(query: Dict) -> Dict:
return query.get(SYSTEM_QUERY_START_DATE) | null |
27,695 | import math
import sys
import time
from json import JSONDecodeError
import backoff
import pendulum
import requests
import simplejson
import singer
from requests.exceptions import ConnectionError, RequestException, Timeout
from singer import metadata, set_currently_syncing
from singer.catalog import Catalog, CatalogEntr... | null |
27,696 | import math
import sys
import time
from json import JSONDecodeError
import backoff
import pendulum
import requests
import simplejson
import singer
from requests.exceptions import ConnectionError, RequestException, Timeout
from singer import metadata, set_currently_syncing
from singer.catalog import Catalog, CatalogEntr... | null |
27,697 | import math
import sys
import time
from json import JSONDecodeError
import backoff
import pendulum
import requests
import simplejson
import singer
from requests.exceptions import ConnectionError, RequestException, Timeout
from singer import metadata, set_currently_syncing
from singer.catalog import Catalog, CatalogEntr... | null |
27,698 | from singer.catalog import Schema
from mage_integrations.sources.catalog import Catalog, CatalogEntry
from mage_integrations.sources.linkedin_ads.tap_linkedin_ads.schema import (
STREAMS,
get_schemas,
)
def discover():
schemas, field_metadata = get_schemas()
catalog = Catalog([])
for stream_name, ... | null |
27,699 | import copy
import datetime
import urllib.parse
from datetime import timedelta
import singer
from singer import (
UNIX_MILLISECONDS_INTEGER_DATETIME_PARSING,
Transformer,
metadata,
metrics,
should_sync_field,
utils,
)
from singer.utils import strftime, strptime_to_utc
from mage_integrations.sour... | null |
27,700 | from datetime import datetime, timedelta
import backoff
import requests
from singer import metrics
import singer
LOGGER = singer.get_logger()
BASE_URL = 'https://api.linkedin.com/v2'
LINKEDIN_TOKEN_URI = 'https://www.linkedin.com/oauth/v2/accessToken'
INTROSPECTION_URI = 'https://www.linkedin.com/oauth/v2/introspectTok... | null |
27,701 | import os
import json
from singer import metadata
STREAMS = {
'accounts': {
'key_properties': ['id'],
'replication_method': 'INCREMENTAL',
'replication_keys': ['last_modified_time']
},
'video_ads': {
'key_properties': ['content_reference'],
'replication_method': 'INCR... | null |
27,702 | import re
from re import sub
from decimal import Decimal
from datetime import datetime, timedelta
import singer
def snake_case_to_camel_case(text):
if not text:
return text
words = text.split('_')
first_word = words[0]
remaining_words = words[1:]
return first_word + ''.join(word.title() f... | null |
27,703 | import re
from re import sub
from decimal import Decimal
from datetime import datetime, timedelta
import singer
LOGGER = singer.get_logger()
def convert_json(this_json):
out = {}
for key in this_json:
try:
new_key = convert(key)
except TypeError as err:
LOGGER.error('Erro... | null |
27,704 | import singer
from singer import metadata
from mage_integrations.sources.sftp.tap_sftp import client
from mage_integrations.sources.sftp.tap_sftp.singer_encodings import json_schema
LOGGER = singer.get_logger()
def discover_streams(config):
streams = []
conn = client.connection(config)
tables = config.ge... | null |
27,705 | STATS = {}
def initialize_table_stats(table_spec):
global STATS
STATS[table_spec['table_name']] = {
'search_prefix': table_spec['search_prefix'],
'search_pattern': table_spec['search_pattern'],
'files': {}
}
def add_file_data(table_spec, filepath, last_modified, row_count):
tabl... | null |
27,706 | import singer
from singer import metadata
from terminaltables import AsciiTable
from mage_integrations.sources.base import write_schema, write_state
from mage_integrations.sources.sftp.tap_sftp import client
from mage_integrations.sources.sftp.tap_sftp.discover import discover_streams
from mage_integrations.sources.sft... | null |
27,707 | import singer
from singer import metadata
from terminaltables import AsciiTable
from mage_integrations.sources.base import write_schema, write_state
from mage_integrations.sources.sftp.tap_sftp import client
from mage_integrations.sources.sftp.tap_sftp.discover import discover_streams
from mage_integrations.sources.sft... | null |
27,708 | import singer
from singer import Transformer, metadata, utils
from mage_integrations.sources.base import write_state
from mage_integrations.sources.sftp.tap_sftp import stats
from mage_integrations.sources.sftp.tap_sftp.aws_ssm import AWS_SSM
from mage_integrations.sources.sftp.tap_sftp.singer_encodings import csv_hand... | null |
27,709 | import os
import gnupg
def gpg_decrypt_to_file(gpg, src_file_path, decrypted_path, passphrase):
with open(src_file_path, 'rb') as file_obj:
gpg.decrypt_file(file_obj, output=decrypted_path, passphrase=passphrase)
return decrypted_path
def initialize_gpg(key, gnupghome):
gpg = gnupg.GPG(gnupghome=gnu... | null |
27,710 | import gzip
import zipfile
The provided code snippet includes necessary dependencies for implementing the `infer` function. Write a Python function `def infer(iterable, file_name)` to solve the following problem:
Uses the incoming file_name and checks the end of the string for supported compression types
Here is the ... | Uses the incoming file_name and checks the end of the string for supported compression types |
27,711 | from mage_integrations.sources.sftp.tap_sftp.aws_ssm import AWS_SSM
from . import csv_handler
SDC_SOURCE_FILE_COLUMN = "_sdc_source_file"
SDC_SOURCE_LINENO_COLUMN = "_sdc_source_lineno"
SDC_SOURCE_LAST_MODIFIED = "_sdc_source_last_modified"
def sample_files(conn, table_spec, files, config,
sample_rate=... | null |
27,712 | import os
import re
import stat
import tempfile
from datetime import datetime
import backoff
import paramiko
import pytz
import singer
from paramiko.ssh_exception import AuthenticationException, SSHException
from mage_integrations.sources.sftp.tap_sftp import decrypt
LOGGER = singer.get_logger()
def handle_backoff(det... | null |
27,713 | import os
import re
import stat
import tempfile
from datetime import datetime
import backoff
import paramiko
import pytz
import singer
from paramiko.ssh_exception import AuthenticationException, SSHException
from mage_integrations.sources.sftp.tap_sftp import decrypt
class SFTPConnection():
def __init__(self,
... | null |
27,714 | import singer
from singer.catalog import Catalog, CatalogEntry, Schema
from mage_integrations.sources.github.tap_github.schema import get_schemas
LOGGER = singer.get_logger()
The provided code snippet includes necessary dependencies for implementing the `discover` function. Write a Python function `def discover(client... | Run the discovery mode, prepare the catalog file and return catalog. |
27,715 | import collections
import singer
from singer import bookmarks
from mage_integrations.sources.github.tap_github.streams import STREAMS
from mage_integrations.sources.messages import write_schema
LOGGER = singer.get_logger()
STREAM_TO_SYNC_FOR_ORGS = ["teams", "team_members", "team_memberships"]
def get_selected_streams(... | Sync selected streams. |
27,716 | import time
import backoff
import requests
import singer
from simplejson import JSONDecodeError
from singer import metrics
LOGGER = singer.get_logger()
class GithubException(Exception):
pass
class Server5xxError(GithubException):
pass
ERROR_CODE_EXCEPTION_MAPPING = {
301: {
"raise_exception": MovedP... | Retrieve the error code and the error message from the response and return custom exceptions accordingly. |
27,717 | import time
import backoff
import requests
import singer
from simplejson import JSONDecodeError
from singer import metrics
LOGGER = singer.get_logger()
class GithubException(Exception):
pass
def calculate_seconds(epoch):
"""
Calculate the seconds to sleep before making a new request.
"""
current = t... | For rate limit errors, get the remaining time before retrying and calculate the time to sleep before making a new request. |
27,718 | import json
import os
import singer
from singer import metadata
from mage_integrations.sources.github.tap_github.streams import STREAMS
def get_abs_path(path):
"""
Get the absolute path for the schema files.
"""
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path)
def load_schema_refer... | Load the schema references, prepare metadata for each streams and return schema and metadata for the catalog. |
27,719 | from datetime import datetime
import singer
from singer import bookmarks, metadata, metrics
The provided code snippet includes necessary dependencies for implementing the `get_bookmark` function. Write a Python function `def get_bookmark(state, repo, stream_name, bookmark_key, start_date)` to solve the following probl... | Return bookmark value if available in the state otherwise return start date |
27,720 | from datetime import datetime
import singer
from singer import bookmarks, metadata, metrics
The provided code snippet includes necessary dependencies for implementing the `get_schema` function. Write a Python function `def get_schema(catalog, stream_id)` to solve the following problem:
Return catalog of the specified ... | Return catalog of the specified stream. |
27,721 | from datetime import datetime
import singer
from singer import bookmarks, metadata, metrics
LOGGER = singer.get_logger()
The provided code snippet includes necessary dependencies for implementing the `get_child_full_url` function. Write a Python function `def get_child_full_url(domain, child_object, repo_path, parent_... | Build the child stream's URL based on the parent and the grandparent's ids. |
27,722 | from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_FORMAT_UUID,
COLUMN_TYPE_INTEGER,
)
from mage_integrations.sources.sql.base import column_type_mapping
def postgres_column_type_mapping(column_type: str, column_format: str = None) -> str:
if COLUMN_FORMAT_DATETIME == colu... | null |
27,723 | from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_FORMAT_UUID,
COLUMN_TYPE_INTEGER,
)
from mage_integrations.sources.sql.base import column_type_mapping
def mssql_column_type_mapping(column_type: str, column_format: str = None) -> str:
if COLUMN_FORMAT_DATETIME == column_... | null |
27,724 | from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_FORMAT_UUID,
COLUMN_TYPE_INTEGER,
)
from mage_integrations.sources.sql.base import column_type_mapping
def mysql_column_type_mapping(column_type: str, column_format: str = None) -> str:
if COLUMN_FORMAT_DATETIME == column_... | null |
27,725 | from singer import metadata
from singer.catalog import Catalog, CatalogEntry
from mage_integrations.sources.postmark.tap_postmark.schema import load_schemas
from mage_integrations.sources.postmark.tap_postmark.streams import STREAMS
The provided code snippet includes necessary dependencies for implementing the `discov... | Load the Stream catalog. Returns: Catalog -- The catalog |
27,726 | import logging
from datetime import datetime, timezone
from typing import Callable, Optional
import singer
from singer.catalog import Catalog, CatalogEntry
from mage_integrations.sources.messages import write_schema
from mage_integrations.sources.postmark.tap_postmark import tools
from mage_integrations.sources.postmar... | Sync data from tap source. Arguments: postmark {Postmark} -- Postmark client state {dict} -- Tap state catalog {Catalog} -- Stream catalog start_date {str} -- Start date |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.