index int64 0 50.7k | project_path stringclasses 279
values | completion_path stringlengths 57 199 | signature_postion stringlengths 3 11 | class_position stringlengths 3 11 | function_name stringlengths 1 62 | class_name stringlengths 0 55 | body_position stringlengths 3 11 | body_position_with_comments stringlengths 3 11 | masked_class stringlengths 14 8.32k | masked_class_with_comment stringlengths 14 8.32k | func_body stringlengths 9 6.72k | func_body_with_comment stringlengths 9 6.72k | len_func_body int64 1 643 | len_input int64 10 2.02k | len_output int64 4 1.9k | total int64 20 2.05k | file_code stringlengths 14 442k | file_code_with_comment stringlengths 14 442k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20,644 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/presenters/pages/models/page_components/pipeline_schedules.py | 63,65 | 59,98 | components | EditComponent | 65,98 | 65,98 | class EditComponent(BaseComponent):
category = ComponentCategory.FORM
operation = OperationType.UPDATE
@classmethod
async def components(self, current_user: User = None, **kwargs) -> List[EditAttributes]:
FILL_FUNC_BODY | class EditComponent(BaseComponent):
category = ComponentCategory.FORM
operation = OperationType.UPDATE
@classmethod
async def components(self, current_user: User = None, **kwargs) -> List[EditAttributes]:
FILL_FUNC_BODY | mapping = {}
pipeline_schedules = kwargs.get('pipeline_schedules') or []
for pipeline_schedule in pipeline_schedules:
resource = PipelineScheduleResource(
pipeline_schedule,
current_user,
api_operation_action=OperationType.UPDATE,
... | mapping = {}
pipeline_schedules = kwargs.get('pipeline_schedules') or []
for pipeline_schedule in pipeline_schedules:
resource = PipelineScheduleResource(
pipeline_schedule,
current_user,
api_operation_action=OperationType.UPDATE,
... | 63 | 66 | 301 | 367 | import asyncio
from typing import List
from mage_ai.api.constants import AttributeOperationType
from mage_ai.api.errors import ApiError
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.resources.PipelineScheduleResource import PipelineScheduleResource
from mage_ai.data_preparation.models.pip... | import asyncio
from typing import List
from mage_ai.api.constants import AttributeOperationType
from mage_ai.api.errors import ApiError
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.resources.PipelineScheduleResource import PipelineScheduleResource
from mage_ai.data_preparation.models.pip... |
20,645 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/blocks.py | 7,8 | 6,14 | get | ApiPipelineBlockAnalysisHandler | 8,14 | 8,14 | class ApiPipelineBlockAnalysisHandler(BaseHandler):
def get(self, pipeline_uuid, block_uuid):
FILL_FUNC_BODY | class ApiPipelineBlockAnalysisHandler(BaseHandler):
def get(self, pipeline_uuid, block_uuid):
FILL_FUNC_BODY | pipeline = Pipeline.get(pipeline_uuid, repo_path=get_repo_path())
block = pipeline.get_block(block_uuid)
if block is None:
raise Exception(f'Block {block_uuid} does not exist in pipeline {pipeline_uuid}')
analyses = block.get_analyses()
self.write(dict(analyses=analys... | pipeline = Pipeline.get(pipeline_uuid, repo_path=get_repo_path())
block = pipeline.get_block(block_uuid)
if block is None:
raise Exception(f'Block {block_uuid} does not exist in pipeline {pipeline_uuid}')
analyses = block.get_analyses()
self.write(dict(analyses=analys... | 24 | 38 | 107 | 145 | from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.server.api.base import BaseHandler
from mage_ai.settings.repo import get_repo_path
class ApiPipelineBlockAnalysisHandler(BaseHandler):
def get(self, pipeline_uuid, block_uuid):
FILL_FUNC_BODY | from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.server.api.base import BaseHandler
from mage_ai.settings.repo import get_repo_path
class ApiPipelineBlockAnalysisHandler(BaseHandler):
def get(self, pipeline_uuid, block_uuid):
FILL_FUNC_BODY |
20,646 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/events.py | 8,9 | 7,14 | post | ApiEventHandler | 9,14 | 9,14 | class ApiEventHandler(BaseHandler):
def post(self):
FILL_FUNC_BODY | class ApiEventHandler(BaseHandler):
def post(self):
FILL_FUNC_BODY | payload = self.get_payload()
EventTrigger().run(payload)
self.write(dict(event=payload))
| payload = self.get_payload()
EventTrigger().run(payload)
self.write(dict(event=payload))
| 5 | 27 | 42 | 69 | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
FILL_FUNC_BODYclass ApiEventMatcherDetailHandl... | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
FILL_FUNC_BODYclass ApiEventMatcherDetailHandl... |
20,647 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/events.py | 17,18 | 14,39 | get | ApiEventMatcherDetailHandler | 18,23 | 18,23 | class ApiEventMatcherDetailHandler(BaseDetailHandler):
model_class = EventMatcher
def get(self, event_matcher_id):
FILL_FUNC_BODY def put(self, event_matcher_id):
event_matcher = self.model_class.query.get(int(event_matcher_id))
payload = self.get_payload()
pipeline_schedule_ids = pa... | class ApiEventMatcherDetailHandler(BaseDetailHandler):
model_class = EventMatcher
def get(self, event_matcher_id):
FILL_FUNC_BODY def put(self, event_matcher_id):
event_matcher = self.model_class.query.get(int(event_matcher_id))
payload = self.get_payload()
pipeline_schedule_ids = pa... | include_attributes = []
if self.get_bool_argument('include_pipeline_schedules', False):
include_attributes.append('pipeline_schedules')
super().get(event_matcher_id, include_attributes=include_attributes)
| include_attributes = []
if self.get_bool_argument('include_pipeline_schedules', False):
include_attributes.append('pipeline_schedules')
super().get(event_matcher_id, include_attributes=include_attributes)
| 9 | 246 | 69 | 315 | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
payload = self.get_payload()
E... | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
payload = self.get_payload()
E... |
20,648 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/events.py | 48,49 | 39,59 | post | ApiEventMatcherListHandler | 49,59 | 49,59 | class ApiEventMatcherListHandler(BaseHandler):
model_class = EventMatcher
def get(self):
event_matchers = EventMatcher.query.all()
collection = [e.to_dict() for e in event_matchers]
self.write(dict(event_matchers=collection))
self.finish()
def post(self):
FILL_FUNC_BODY | class ApiEventMatcherListHandler(BaseHandler):
model_class = EventMatcher
def get(self):
event_matchers = EventMatcher.query.all()
collection = [e.to_dict() for e in event_matchers]
self.write(dict(event_matchers=collection))
self.finish()
def post(self):
FILL_FUNC_BODY | arr = json.loads(self.request.body).get('event_matchers', [])
if len(arr) == 0:
arr.append(self.get_payload())
event_matchers = EventMatcher.upsert_batch(arr)
if len(event_matchers) >= 2:
self.write(dict(event_matchers=[em.to_dict() for em in event_matchers]))
... | arr = json.loads(self.request.body).get('event_matchers', [])
if len(arr) == 0:
arr.append(self.get_payload())
event_matchers = EventMatcher.upsert_batch(arr)
if len(event_matchers) >= 2:
self.write(dict(event_matchers=[em.to_dict() for em in event_matchers]))
... | 23 | 104 | 146 | 250 | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
payload = self.get_payload()
E... | from .base import BaseDetailHandler, BaseHandler
from mage_ai.orchestration.db.models.schedules import EventMatcher, PipelineSchedule
from mage_ai.orchestration.triggers.event_trigger import EventTrigger
import json
class ApiEventHandler(BaseHandler):
def post(self):
payload = self.get_payload()
E... |
20,649 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/integration_sources.py | 14,15 | 1,73 | build_integration_module_info | 15,64 | 15,64 | import importlib
import json
import subprocess
import traceback
from typing import Dict, List
from mage_ai.data_integrations.utils.settings import get_uuid
from mage_ai.data_preparation.models.constants import PYTHON_COMMAND
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def ... | import importlib
import json
import subprocess
import traceback
from typing import Dict, List
from mage_ai.data_integrations.utils.settings import get_uuid
from mage_ai.data_preparation.models.constants import PYTHON_COMMAND
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def ... | d = option.copy()
module_name = d.get('module_name', d['name'].replace(' ', ''))
uuid = get_uuid(d)
d['uuid'] = uuid
try:
module = importlib.import_module(f"mage_integrations.{key}.{uuid}")
absolute_file_path = '/'.join(module.__file__.split('/')[:-2])
# have the source REA... | d = option.copy()
module_name = d.get('module_name', d['name'].replace(' ', ''))
uuid = get_uuid(d)
d['uuid'] = uuid
try:
module = importlib.import_module(f"mage_integrations.{key}.{uuid}")
absolute_file_path = '/'.join(module.__file__.split('/')[:-2])
# have the source REA... | 134 | 203 | 634 | 837 | import importlib
import json
import subprocess
import traceback
from typing import Dict, List
from mage_ai.data_integrations.utils.settings import get_uuid
from mage_ai.data_preparation.models.constants import PYTHON_COMMAND
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def ... | import importlib
import json
import subprocess
import traceback
from typing import Dict, List
from mage_ai.data_integrations.utils.settings import get_uuid
from mage_ai.data_preparation.models.constants import PYTHON_COMMAND
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def ... | |
20,650 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/triggers.py | 17,19 | 14,57 | post | ApiTriggerPipelineHandler | 19,57 | 19,57 | class ApiTriggerPipelineHandler(BaseHandler):
model_class = PipelineRun
@safe_db_query
def post(self, pipeline_schedule_id, token: str = None):
FILL_FUNC_BODY | class ApiTriggerPipelineHandler(BaseHandler):
model_class = PipelineRun
@safe_db_query
def post(self, pipeline_schedule_id, token: str = None):
FILL_FUNC_BODY | pipeline_schedule = PipelineSchedule.query.get(int(pipeline_schedule_id))
if not pipeline_schedule:
raise ApiError(ApiError.RESOURCE_NOT_FOUND)
if token is None:
token = get_bearer_auth_token_from_headers(self.request.headers)
if ScheduleType.API == pipeline_sch... | pipeline_schedule = PipelineSchedule.query.get(int(pipeline_schedule_id))
if not pipeline_schedule:
raise ApiError(ApiError.RESOURCE_NOT_FOUND)
if token is None:
token = get_bearer_auth_token_from_headers(self.request.headers)
if ScheduleType.API == pipeline_sch... | 84 | 61 | 407 | 468 | import json
from mage_ai.api.errors import ApiError
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.triggers import ScheduleType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.schedules import PipelineRun, PipelineSchedule
from... | import json
from mage_ai.api.errors import ApiError
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.triggers import ScheduleType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.schedules import PipelineRun, PipelineSchedule
from... |
20,651 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/v1.py | 20,21 | 5,28 | put | ApiChildDetailHandler | 21,28 | 21,28 | class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
child_pk=child_pk,
))
async def get(self, resource, pk, child, child_pk):
re... | class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
child_pk=child_pk,
))
async def get(self, resource, pk, child, child_pk):
re... | return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
child_pk=child_pk,
))
| return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
child_pk=child_pk,
))
| 9 | 165 | 51 | 216 | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... |
20,652 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/v1.py | 29,30 | 28,42 | get | ApiChildListHandler | 30,35 | 30,35 | class ApiChildListHandler(BaseApiHandler):
async def get(self, resource, pk, child):
FILL_FUNC_BODY async def post(self, resource, pk, child):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
))
| class ApiChildListHandler(BaseApiHandler):
async def get(self, resource, pk, child):
FILL_FUNC_BODY async def post(self, resource, pk, child):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
))
| return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
))
| return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
))
| 8 | 86 | 38 | 124 | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... |
20,653 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/v1.py | 68,74 | 67,82 | initialize | ApiListHandler | 74,77 | 74,77 | class ApiListHandler(BaseApiHandler):
def initialize(
self,
resource: str,
bypass_oauth_check: bool = False,
is_health_check: bool = False,
):
FILL_FUNC_BODY async def get(self):
return await execute_operation(self, self.resource)
async def post(self):
ret... | class ApiListHandler(BaseApiHandler):
def initialize(
self,
resource: str,
bypass_oauth_check: bool = False,
is_health_check: bool = False,
):
FILL_FUNC_BODY async def get(self):
return await execute_operation(self, self.resource)
async def post(self):
ret... | super().initialize(bypass_oauth_check=bypass_oauth_check, is_health_check=is_health_check)
self.resource = resource
| super().initialize(bypass_oauth_check=bypass_oauth_check, is_health_check=is_health_check)
self.resource = resource
| 5 | 110 | 48 | 158 | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... |
20,654 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/v1.py | 53,54 | 42,59 | put | ApiResourceDetailHandler | 54,59 | 54,59 | class ApiResourceDetailHandler(BaseApiHandler):
async def delete(self, resource, pk):
return await execute_operation(self, resource, **dict(
pk=pk,
))
async def get(self, resource, pk):
return await execute_operation(self, resource, **dict(
pk=pk,
))
... | class ApiResourceDetailHandler(BaseApiHandler):
async def delete(self, resource, pk):
return await execute_operation(self, resource, **dict(
pk=pk,
))
async def get(self, resource, pk):
return await execute_operation(self, resource, **dict(
pk=pk,
))
... | return await execute_operation(self, resource, **dict(
pk=pk,
))
| return await execute_operation(self, resource, **dict(
pk=pk,
))
| 7 | 115 | 33 | 148 | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... |
20,655 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/api/v1.py | 63,64 | 59,67 | post | ApiResourceListHandler | 64,67 | 64,67 | class ApiResourceListHandler(BaseApiHandler):
async def get(self, resource):
return await execute_operation(self, resource)
async def post(self, resource):
FILL_FUNC_BODY | class ApiResourceListHandler(BaseApiHandler):
async def get(self, resource):
return await execute_operation(self, resource)
async def post(self, resource):
FILL_FUNC_BODY | return await execute_operation(self, resource)
| return await execute_operation(self, resource)
| 4 | 55 | 17 | 72 | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... | from mage_ai.api.views import execute_operation
from mage_ai.server.api.base import BaseApiHandler
class ApiChildDetailHandler(BaseApiHandler):
async def delete(self, resource, pk, child, child_pk):
return await execute_operation(self, resource, **dict(
pk=pk,
child=child,
... |
20,657 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/data/models.py | 269,270 | 226,280 | get_feature_set | Pipeline | 270,274 | 270,274 | class Pipeline(Model):
def __init__(self, id=None, path=None, feature_set_id=None, pipeline=None, api_key=None):
super().__init__(id=id, path=path)
# Update metadata
try:
metadata = self.metadata
except Exception:
self.metadata = {}
metadata = sel... | class Pipeline(Model):
def __init__(self, id=None, path=None, feature_set_id=None, pipeline=None, api_key=None):
super().__init__(id=id, path=path)
# Update metadata
try:
metadata = self.metadata
except Exception:
self.metadata = {}
metadata = sel... | feature_set_id = self.metadata.get('feature_set_id')
if feature_set_id is not None:
return FeatureSet(id=feature_set_id)
| feature_set_id = self.metadata.get('feature_set_id')
if feature_set_id is not None:
return FeatureSet(id=feature_set_id)
| 10 | 453 | 51 | 504 | from mage_ai.data_cleaner.pipelines.base import BasePipeline
from mage_ai.server.client.mage import Mage
from mage_ai.server.data.base import Model
from mage_ai.shared.constants import SAMPLE_SIZE
from mage_ai.shared.hash import merge_dict
from mage_ai.server.logger import Logger
import os
import os.path
logger = Logg... | from mage_ai.data_cleaner.pipelines.base import BasePipeline
from mage_ai.server.client.mage import Mage
from mage_ai.server.data.base import Model
from mage_ai.shared.constants import SAMPLE_SIZE
from mage_ai.shared.hash import merge_dict
from mage_ai.server.logger import Logger
import os
import os.path
logger = Logg... |
20,658 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/docs_server.py | 8,9 | 1,27 | get_dbt_target_path | 9,12 | 9,12 | import os
import socketserver
from http.server import SimpleHTTPRequestHandler
from mage_ai.settings.repo import get_repo_path
def get_dbt_target_path():
FILL_FUNC_BODYdef run_docs_server():
target_path = get_dbt_target_path()
if not os.path.exists(target_path):
os.makedirs(target_path)
os.chdir... | import os
import socketserver
from http.server import SimpleHTTPRequestHandler
from mage_ai.settings.repo import get_repo_path
def get_dbt_target_path():
FILL_FUNC_BODYdef run_docs_server():
target_path = get_dbt_target_path()
if not os.path.exists(target_path):
os.makedirs(target_path)
os.chdir... | return os.path.join(get_repo_path(), 'dbt', 'target')
| return os.path.join(get_repo_path(), 'dbt', 'target')
| 4 | 195 | 27 | 222 | import os
import socketserver
from http.server import SimpleHTTPRequestHandler
from mage_ai.settings.repo import get_repo_path
def get_dbt_target_path():
FILL_FUNC_BODYdef run_docs_server():
target_path = get_dbt_target_path()
if not os.path.exists(target_path):
os.makedirs(target_path)
os.chdir... | import os
import socketserver
from http.server import SimpleHTTPRequestHandler
from mage_ai.settings.repo import get_repo_path
def get_dbt_target_path():
FILL_FUNC_BODYdef run_docs_server():
target_path = get_dbt_target_path()
if not os.path.exists(target_path):
os.makedirs(target_path)
os.chdir... | |
20,659 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/execution_manager.py | 27,31 | 1,111 | check_pipeline_process_status | 31,43 | 31,43 | from distutils.file_util import copy_file
from mage_ai.data_preparation.models.constants import PIPELINE_CONFIG_FILE
from mage_ai.data_preparation.models.pipeline import Pipeline
from typing import Callable
import asyncio
import multiprocessing
import os
import shutil
class PipelineExecution:
"""
Singleton cl... | from distutils.file_util import copy_file
from mage_ai.data_preparation.models.constants import PIPELINE_CONFIG_FILE
from mage_ai.data_preparation.models.pipeline import Pipeline
from typing import Callable
import asyncio
import multiprocessing
import os
import shutil
class PipelineExecution:
"""
Singleton cl... | current_process = pipeline_execution.current_pipeline_process
is_alive = False
if current_process:
is_alive = current_process.is_alive()
status = 'running' if is_alive else 'not running'
publish_message(
f'Pipeline {pipeline.uuid} is currently {status}.',
metadata=dict(pipel... | current_process = pipeline_execution.current_pipeline_process
is_alive = False
if current_process:
is_alive = current_process.is_alive()
status = 'running' if is_alive else 'not running'
publish_message(
f'Pipeline {pipeline.uuid} is currently {status}.',
metadata=dict(pipel... | 27 | 888 | 122 | 1,010 | from distutils.file_util import copy_file
from mage_ai.data_preparation.models.constants import PIPELINE_CONFIG_FILE
from mage_ai.data_preparation.models.pipeline import Pipeline
from typing import Callable
import asyncio
import multiprocessing
import os
import shutil
class PipelineExecution:
"""
Singleton cl... | from distutils.file_util import copy_file
from mage_ai.data_preparation.models.constants import PIPELINE_CONFIG_FILE
from mage_ai.data_preparation.models.pipeline import Pipeline
from typing import Callable
import asyncio
import multiprocessing
import os
import shutil
class PipelineExecution:
"""
Singleton cl... | |
20,660 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/kernel_output_parser.py | 23,24 | 1,85 | parse_output_message | 24,85 | 24,85 | from enum import Enum
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
class DataType(str, Enum):
DATA_FRAME = 'data_frame'
IMAGE_PNG = 'image/png'
PROGRESS = 'progress'
TABLE = 'table'
TEXT = 'text'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
COMMS_MES... | from enum import Enum
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
class DataType(str, Enum):
DATA_FRAME = 'data_frame'
IMAGE_PNG = 'image/png'
PROGRESS = 'progress'
TABLE = 'table'
TEXT = 'text'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
COMMS_MES... | data_content = None
data_type = None
error = None
header = message['header']
msg_type = header['msg_type']
parent_header = message['parent_header']
msg_id = parent_header.get('msg_id')
content = message['content']
execution_state = content.get('execution_state')
traceback = c... | data_content = None
data_type = None
error = None
header = message['header']
msg_type = header['msg_type']
parent_header = message['parent_header']
msg_id = parent_header.get('msg_id')
content = message['content']
execution_state = content.get('execution_state')
traceback = c... | 164 | 189 | 696 | 885 | from enum import Enum
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
class DataType(str, Enum):
DATA_FRAME = 'data_frame'
IMAGE_PNG = 'image/png'
PROGRESS = 'progress'
TABLE = 'table'
TEXT = 'text'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
COMMS_MES... | from enum import Enum
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
class DataType(str, Enum):
DATA_FRAME = 'data_frame'
IMAGE_PNG = 'image/png'
PROGRESS = 'progress'
TABLE = 'table'
TEXT = 'text'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
COMMS_MES... | |
20,661 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/logger.py | 13,14 | 9,23 | new_logger_with_verbosity | Logger | 14,23 | 14,23 | class Logger:
def new_server_logger(self, name):
return self.new_logger_with_verbosity(name, SERVER_VERBOSITY)
def new_logger_with_verbosity(self, name, level: str):
FILL_FUNC_BODY | class Logger:
def new_server_logger(self, name):
return self.new_logger_with_verbosity(name, SERVER_VERBOSITY)
def new_logger_with_verbosity(self, name, level: str):
FILL_FUNC_BODY | if is_deus_ex_machina():
server_logger = DX_LOGGER
else:
server_logger = logging.getLogger(name)
if LoggingLevel.is_valid_level(level):
server_logger.setLevel(level.upper())
else:
print(f'invalid verbosity {level} for logger {name}')
... | if is_deus_ex_machina():
server_logger = DX_LOGGER
else:
server_logger = logging.getLogger(name)
if LoggingLevel.is_valid_level(level):
server_logger.setLevel(level.upper())
else:
print(f'invalid verbosity {level} for logger {name}')
... | 21 | 73 | 107 | 180 | import logging
from mage_ai.settings import SERVER_VERBOSITY
from mage_ai.shared.custom_logger import DX_LOGGER
from mage_ai.shared.environments import is_deus_ex_machina
from mage_ai.shared.logger import LoggingLevel
class Logger:
def new_server_logger(self, name):
return self.new_logger_with_verbosity(... | import logging
from mage_ai.settings import SERVER_VERBOSITY
from mage_ai.shared.custom_logger import DX_LOGGER
from mage_ai.shared.environments import is_deus_ex_machina
from mage_ai.shared.logger import LoggingLevel
class Logger:
def new_server_logger(self, name):
return self.new_logger_with_verbosity(... |
20,662 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/server/subscriber.py | 8,9 | 1,25 | get_messages | 9,25 | 9,25 | from datetime import datetime
from mage_ai.server.active_kernel import get_active_kernel_client
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def get_messages(callback=None):
FILL_FUNC_BODY | from datetime import datetime
from mage_ai.server.active_kernel import get_active_kernel_client
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def get_messages(callback=None):
FILL_FUNC_BODY | now = datetime.utcnow()
while True:
try:
client = get_active_kernel_client()
message = client.get_iopub_msg(timeout=1)
if message.get('content'):
if callback:
callback(message)
else:
logger.warn... | now = datetime.utcnow()
while True:
try:
client = get_active_kernel_client()
message = client.get_iopub_msg(timeout=1)
if message.get('content'):
if callback:
callback(message)
else:
logger.warn... | 35 | 75 | 148 | 223 | from datetime import datetime
from mage_ai.server.active_kernel import get_active_kernel_client
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def get_messages(callback=None):
FILL_FUNC_BODY | from datetime import datetime
from mage_ai.server.active_kernel import get_active_kernel_client
from mage_ai.server.logger import Logger
logger = Logger().new_server_logger(__name__)
def get_messages(callback=None):
FILL_FUNC_BODY | |
20,665 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/airbyte/server.py | 20,21 | 6,28 | get_client | AirbyteServer | 21,28 | 21,28 | class AirbyteServer():
def __init__(self, config: AirbyteConfig):
self.config = config
@property
def protocol(self) -> str:
return 'https' if self.config.use_ssl else 'http'
@property
def base_url(self) -> str:
base_path = f'{self.config.host}:{self.config.port}'
r... | class AirbyteServer():
def __init__(self, config: AirbyteConfig):
self.config = config
@property
def protocol(self) -> str:
return 'https' if self.config.use_ssl else 'http'
@property
def base_url(self) -> str:
base_path = f'{self.config.host}:{self.config.port}'
r... | return AirbyteClient(
base_url=self.base_url,
logger=logger,
password=self.config.password,
timeout=timeout,
username=self.config.username,
)
| return AirbyteClient(
base_url=self.base_url,
logger=logger,
password=self.config.password,
timeout=timeout,
username=self.config.username,
)
| 8 | 167 | 61 | 228 | from mage_ai.services.airbyte.client import AirbyteClient
from mage_ai.services.airbyte.config import AirbyteConfig
import logging
class AirbyteServer():
def __init__(self, config: AirbyteConfig):
self.config = config
@property
def protocol(self) -> str:
return 'https' if self.config.use_... | from mage_ai.services.airbyte.client import AirbyteClient
from mage_ai.services.airbyte.config import AirbyteConfig
import logging
class AirbyteServer():
def __init__(self, config: AirbyteConfig):
self.config = config
@property
def protocol(self) -> str:
return 'https' if self.config.use_... |
20,666 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/aws/ecs/ecs.py | 8,13 | 1,93 | run_task | 13,55 | 13,55 | import json
from typing import Dict, List, Union
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
def run_task(
command: Union[str, Dict],
ecs_config: EcsConfig,
wait_for_completion: bool = True,
) -> None:
FILL_FUNC_BODYdef stop_task(task_arn: s... | import json
from typing import Dict, List, Union
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
def run_task(
command: Union[str, Dict],
ecs_config: EcsConfig,
wait_for_completion: bool = True,
) -> None:
FILL_FUNC_BODYdef stop_task(task_arn: s... | if type(ecs_config) is dict:
ecs_config = EcsConfig.load(config=ecs_config)
client = get_aws_boto3_client('ecs')
response = client.run_task(**ecs_config.get_task_config(command=command))
print(json.dumps(response, indent=4, default=str))
wait_for_completion = False if ecs_config.wait_timeou... | if type(ecs_config) is dict:
ecs_config = EcsConfig.load(config=ecs_config)
client = get_aws_boto3_client('ecs')
response = client.run_task(**ecs_config.get_task_config(command=command))
print(json.dumps(response, indent=4, default=str))
wait_for_completion = False if ecs_config.wait_timeou... | 108 | 415 | 505 | 920 | import json
from typing import Dict, List, Union
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
def run_task(
command: Union[str, Dict],
ecs_config: EcsConfig,
wait_for_completion: bool = True,
) -> None:
FILL_FUNC_BODYdef stop_task(task_arn: s... | import json
from typing import Dict, List, Union
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
def run_task(
command: Union[str, Dict],
ecs_config: EcsConfig,
wait_for_completion: bool = True,
) -> None:
FILL_FUNC_BODYdef stop_task(task_arn: s... | |
20,667 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/aws/emr/config.py | 40,46 | 25,120 | get_instances_config | EmrConfig | 46,104 | 46,104 | @dataclass
class EmrConfig(BaseConfig):
bootstrap_script_path: str = None
ec2_key_name: str = None
ec2_key_path: str = None
master_security_group: str = None
slave_security_group: str = None
master_instance_type: str = DEFAULT_INSTANCE_TYPE
master_spark_properties: Dict = field(default_facto... | @dataclass
class EmrConfig(BaseConfig):
bootstrap_script_path: str = None
ec2_key_name: str = None
ec2_key_path: str = None
master_security_group: str = None
slave_security_group: str = None
master_instance_type: str = DEFAULT_INSTANCE_TYPE
master_spark_properties: Dict = field(default_facto... | market = 'ON_DEMAND'
instances_config = {
'KeepJobFlowAliveWhenNoSteps': keep_alive,
'InstanceGroups': [
dict(
Name='AmazonEMRMaster',
Market=market,
InstanceRole='MASTER',
InstanceTyp... | market = 'ON_DEMAND'
instances_config = {
'KeepJobFlowAliveWhenNoSteps': keep_alive,
'InstanceGroups': [
dict(
Name='AmazonEMRMaster',
Market=market,
InstanceRole='MASTER',
InstanceTyp... | 97 | 487 | 637 | 1,124 | import os
from dataclasses import dataclass, field
from typing import Dict, List
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import merge_dict
DEFAULT_DRIVER_MEMORY = '32000M'
DEFAULT_INSTANCE_TYPE = 'r5.4xlarge'
INSTANCE_DRIVER_MEMORY_MAPPING = {
'r5.2xlarge': '16000M',
'r5.xlarge':... | import os
from dataclasses import dataclass, field
from typing import Dict, List
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import merge_dict
DEFAULT_DRIVER_MEMORY = '32000M'
DEFAULT_INSTANCE_TYPE = 'r5.4xlarge'
INSTANCE_DRIVER_MEMORY_MAPPING = {
'r5.2xlarge': '16000M',
'r5.xlarge':... |
20,668 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/aws/emr/launcher.py | 9,17 | 1,62 | create_cluster | 32,62 | 17,62 | from typing import Dict
from mage_ai.data_preparation.repo_manager import RepoConfig
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import create_a_new_cluster
from mage_ai.services.aws.emr.resource_manager import EmrResourceManager
def create_cluster(
project_path: str,
... | from typing import Dict
from mage_ai.data_preparation.repo_manager import RepoConfig
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import create_a_new_cluster
from mage_ai.services.aws.emr.resource_manager import EmrResourceManager
def create_cluster(
project_path: str,
... | if tags is None:
tags = dict()
print(f'Creating EMR cluster for project: {project_path}')
repo_config = RepoConfig(project_path)
# Upload bootstrap script
resource_manager = EmrResourceManager(
repo_config.s3_bucket,
repo_config.s3_path_prefix,
bootstrap_script_path=b... | """
Create an EMR (Elastic MapReduce) cluster for a specified project.
Args:
project_path (str): The path to the Mage project.
done_status (str, optional): The status to consider the cluster as done
(default is 'WAITING').
idle_timeout (int, optional): The idle timeout i... | 58 | 338 | 322 | 660 | from typing import Dict
from mage_ai.data_preparation.repo_manager import RepoConfig
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import create_a_new_cluster
from mage_ai.services.aws.emr.resource_manager import EmrResourceManager
def create_cluster(
project_path: str,
... | from typing import Dict
from mage_ai.data_preparation.repo_manager import RepoConfig
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import create_a_new_cluster
from mage_ai.services.aws.emr.resource_manager import EmrResourceManager
def create_cluster(
project_path: str,
... | |
20,669 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/aws/emr/resource_manager.py | 35,36 | 7,44 | upload_bootstrap_script | EmrResourceManager | 36,44 | 36,44 | class EmrResourceManager:
def __init__(
self,
s3_bucket: str,
s3_path_prefix: str,
bootstrap_script_path: str = None,
):
self.s3_bucket = s3_bucket
self.s3_path_prefix = s3_path_prefix or ''
if self.s3_bucket is None:
raise Exception('Please sp... | class EmrResourceManager:
def __init__(
self,
s3_bucket: str,
s3_path_prefix: str,
bootstrap_script_path: str = None,
):
self.s3_bucket = s3_bucket
self.s3_path_prefix = s3_path_prefix or ''
if self.s3_bucket is None:
raise Exception('Please sp... | if self.local_bootstrap_script_path is None:
bootstrap_script_code = template_env.get_template(
'pipeline_execution/emr_bootstrap.sh',
).render()
else:
with open(self.local_bootstrap_script_path, 'r', encoding='utf-8') as f:
bootstrap_s... | if self.local_bootstrap_script_path is None:
bootstrap_script_code = template_env.get_template(
'pipeline_execution/emr_bootstrap.sh',
).render()
else:
with open(self.local_bootstrap_script_path, 'r', encoding='utf-8') as f:
bootstrap_s... | 21 | 361 | 139 | 500 | import posixpath
from mage_ai.data_preparation.templates.utils import template_env
from mage_ai.services.aws.s3 import s3
class EmrResourceManager:
def __init__(
self,
s3_bucket: str,
s3_path_prefix: str,
bootstrap_script_path: str = None,
):
self.s3_bucket = s3_bucket... | import posixpath
from mage_ai.data_preparation.templates.utils import template_env
from mage_ai.services.aws.s3 import s3
class EmrResourceManager:
def __init__(
self,
s3_bucket: str,
s3_path_prefix: str,
bootstrap_script_path: str = None,
):
self.s3_bucket = s3_bucket... |
20,670 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/aws/events/events.py | 9,10 | 1,54 | get_all_event_rules | 10,28 | 10,28 | import os
import uuid
from mage_ai.services.aws import get_aws_boto3_client
EVENT_RULE_LIMIT = 100
def get_all_event_rules():
FILL_FUNC_BODYdef update_event_rule_targets(name):
lambda_function_arn = os.getenv('LAMBDA_FUNCTION_ARN')
lambda_function_name = os.getenv('LAMBDA_FUNCTION_NAME')
if lambda_funct... | import os
import uuid
from mage_ai.services.aws import get_aws_boto3_client
EVENT_RULE_LIMIT = 100
def get_all_event_rules():
FILL_FUNC_BODYdef update_event_rule_targets(name):
lambda_function_arn = os.getenv('LAMBDA_FUNCTION_ARN')
lambda_function_name = os.getenv('LAMBDA_FUNCTION_NAME')
if lambda_funct... | client = get_aws_boto3_client('events')
response = client.list_rules(
Limit=EVENT_RULE_LIMIT
)
formatted_rules = [
dict(
name=r['Name'],
state=r['State'],
description=r.get('Description'),
schedule_expression=r.get('ScheduleExpression'),
... | client = get_aws_boto3_client('events')
response = client.list_rules(
Limit=EVENT_RULE_LIMIT
)
formatted_rules = [
dict(
name=r['Name'],
state=r['State'],
description=r.get('Description'),
schedule_expression=r.get('ScheduleExpression'),
... | 25 | 450 | 148 | 598 | import os
import uuid
from mage_ai.services.aws import get_aws_boto3_client
EVENT_RULE_LIMIT = 100
def get_all_event_rules():
FILL_FUNC_BODYdef update_event_rule_targets(name):
lambda_function_arn = os.getenv('LAMBDA_FUNCTION_ARN')
lambda_function_name = os.getenv('LAMBDA_FUNCTION_NAME')
if lambda_funct... | import os
import uuid
from mage_ai.services.aws import get_aws_boto3_client
EVENT_RULE_LIMIT = 100
def get_all_event_rules():
FILL_FUNC_BODYdef update_event_rule_targets(name):
lambda_function_arn = os.getenv('LAMBDA_FUNCTION_ARN')
lambda_function_name = os.getenv('LAMBDA_FUNCTION_NAME')
if lambda_funct... | |
20,671 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/dbt/dbt.py | 93,110 | 13,176 | trigger_job_run | DbtCloudClient | 135,176 | 110,176 | class DbtCloudClient(HttpClient):
"""
API doc: https://docs.getdbt.com/dbt-cloud/api-v2
"""
BASE_URL = DBT_CLOUD_BASE_URL
def __init__(self, config: Union[Dict, DbtConfig]):
if type(config) is dict:
self.config = DbtConfig.load(config=config)
else:
self.conf... | class DbtCloudClient(HttpClient):
"""
API doc: https://docs.getdbt.com/dbt-cloud/api-v2
"""
BASE_URL = DBT_CLOUD_BASE_URL
def __init__(self, config: Union[Dict, DbtConfig]):
if type(config) is dict:
self.config = DbtConfig.load(config=config)
else:
self.conf... | job_run_response = self.make_request(
f'/{self.config.account_id}/jobs/{job_id}/run',
method='POST',
payload=dict(
cause=cause,
git_sha=git_sha,
schema_override=schema_override,
dbt_version_override=dbt_version_o... | """Kick off a run for a job. When this endpoint returns a successful response,
a new run will be enqueued for the account. Users can poll the Get run endpoint to
poll the run until it completes. After the run has completed, users can use the Get
run artifact endpoint to download artifact... | 102 | 1,438 | 554 | 1,992 | from datetime import datetime, timedelta
from mage_ai.services.dbt.config import DbtConfig
from mage_ai.services.dbt.constants import (
DBT_CLOUD_BASE_URL,
DEFAULT_POLL_INTERVAL,
DbtCloudJobRunStatus,
)
from mage_ai.shared.http_client import HttpClient
from typing import Dict, List, Optional, Union
import t... | from datetime import datetime, timedelta
from mage_ai.services.dbt.config import DbtConfig
from mage_ai.services.dbt.constants import (
DBT_CLOUD_BASE_URL,
DEFAULT_POLL_INTERVAL,
DbtCloudJobRunStatus,
)
from mage_ai.shared.http_client import HttpClient
from typing import Dict, List, Optional, Union
import t... |
20,672 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/discord/config.py | 10,12 | 6,13 | is_valid | DiscordConfig | 12,13 | 12,13 | @dataclass
class DiscordConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class DiscordConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return self.webhook_url is not None and self.webhook_url != 'None'
| return self.webhook_url is not None and self.webhook_url != 'None'
| 9 | 52 | 25 | 77 | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class DiscordConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class DiscordConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY |
20,673 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/email/config.py | 18,20 | 7,21 | is_valid | EmailConfig | 20,21 | 20,21 | @dataclass
class EmailConfig(BaseConfig):
smtp_host: str
smtp_mail_from: str
smtp_user: str = None
smtp_password: str = None
smtp_starttls: bool = True
smtp_ssl: bool = False
smtp_port: int = 587
to_emails: List[str] = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class EmailConfig(BaseConfig):
smtp_host: str
smtp_mail_from: str
smtp_user: str = None
smtp_password: str = None
smtp_starttls: bool = True
smtp_ssl: bool = False
smtp_port: int = 587
to_emails: List[str] = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return len(self.to_emails or []) > 0
| return len(self.to_emails or []) > 0
| 6 | 126 | 17 | 143 | from dataclasses import dataclass
from typing import List
from mage_ai.shared.config import BaseConfig
@dataclass
class EmailConfig(BaseConfig):
smtp_host: str
smtp_mail_from: str
smtp_user: str = None
smtp_password: str = None
smtp_starttls: bool = True
smtp_ssl: bool = False
smtp_port: ... | from dataclasses import dataclass
from typing import List
from mage_ai.shared.config import BaseConfig
@dataclass
class EmailConfig(BaseConfig):
smtp_host: str
smtp_mail_from: str
smtp_user: str = None
smtp_password: str = None
smtp_starttls: bool = True
smtp_ssl: bool = False
smtp_port: ... |
20,674 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/email/email.py | 7,13 | 1,30 | send_email | 13,30 | 13,30 | import smtplib
from email.message import EmailMessage
from mage_ai.services.email.config import EmailConfig
def send_email(
config: EmailConfig,
subject: str = None,
message: str = None,
verbose: bool = True,
):
FILL_FUNC_BODY | import smtplib
from email.message import EmailMessage
from mage_ai.services.email.config import EmailConfig
def send_email(
config: EmailConfig,
subject: str = None,
message: str = None,
verbose: bool = True,
):
FILL_FUNC_BODY | if subject is None or message is None:
return
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = config.smtp_mail_from
msg['To'] = ', '.join(config.to_emails)
msg.set_content(message)
if verbose:
print(msg)
server = smtplib.SMTP(config.smtp_host, config.smtp_port... | if subject is None or message is None:
return
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = config.smtp_mail_from
msg['To'] = ', '.join(config.to_emails)
msg.set_content(message)
if verbose:
print(msg)
server = smtplib.SMTP(config.smtp_host, config.smtp_port... | 45 | 82 | 206 | 288 | import smtplib
from email.message import EmailMessage
from mage_ai.services.email.config import EmailConfig
def send_email(
config: EmailConfig,
subject: str = None,
message: str = None,
verbose: bool = True,
):
FILL_FUNC_BODY | import smtplib
from email.message import EmailMessage
from mage_ai.services.email.config import EmailConfig
def send_email(
config: EmailConfig,
subject: str = None,
message: str = None,
verbose: bool = True,
):
FILL_FUNC_BODY | |
20,675 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/google_chat/config.py | 9,11 | 5,12 | is_valid | GoogleChatConfig | 11,12 | 11,12 | @dataclass
class GoogleChatConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class GoogleChatConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return self.webhook_url is not None and self.webhook_url != 'None'
| return self.webhook_url is not None and self.webhook_url != 'None'
| 9 | 52 | 25 | 77 | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class GoogleChatConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class GoogleChatConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY |
20,676 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/hightouch/hightouch.py | 52,59 | 15,98 | sync_and_poll | HightouchClient | 59,98 | 59,98 | class HightouchClient(HttpClient):
BASE_URL = HIGHTOUCH_BASE_URL
def __init__(self, config: Union[Dict, HightouchConfig]):
if type(config) is dict:
self.config = HightouchConfig.load(config=config)
else:
self.config = config
self.headers = {
'Content-... | class HightouchClient(HttpClient):
BASE_URL = HIGHTOUCH_BASE_URL
def __init__(self, config: Union[Dict, HightouchConfig]):
if type(config) is dict:
self.config = HightouchConfig.load(config=config)
else:
self.config = config
self.headers = {
'Content-... | trigger_response = self.trigger_sync(sync_id, payload=payload)
run_id = trigger_response.get('id')
if not run_id:
raise Exception(f'Failed to trigger Hightouch sync {sync_id}')
poll_start = datetime.now()
while True:
sync_run = self.list_sync_runs(sync_id,... | trigger_response = self.trigger_sync(sync_id, payload=payload)
run_id = trigger_response.get('id')
if not run_id:
raise Exception(f'Failed to trigger Hightouch sync {sync_id}')
poll_start = datetime.now()
while True:
sync_run = self.list_sync_runs(sync_id,... | 142 | 493 | 549 | 1,042 | from datetime import datetime, timedelta
from mage_ai.services.hightouch.config import HightouchConfig
from mage_ai.services.hightouch.constants import (
HIGHTOUCH_BASE_URL,
DEFAULT_POLL_INTERVAL,
PENDING_STATUSES,
SUCCESS,
TERMINAL_STATUSES,
)
from mage_ai.shared.http_client import HttpClient
from ... | from datetime import datetime, timedelta
from mage_ai.services.hightouch.config import HightouchConfig
from mage_ai.services.hightouch.constants import (
HIGHTOUCH_BASE_URL,
DEFAULT_POLL_INTERVAL,
PENDING_STATUSES,
SUCCESS,
TERMINAL_STATUSES,
)
from mage_ai.shared.http_client import HttpClient
from ... |
20,677 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/opsgenie/config.py | 15,17 | 6,19 | is_valid | OpsgenieConfig | 17,19 | 17,19 | @dataclass
class OpsgenieConfig(BaseConfig):
url: str = None
api_key: str = None
priority: str = "P3"
responders: List[Dict] = field(default_factory=list)
tags: List = field(default_factory=list)
details: Dict = field(default_factory=dict)
@property
def is_valid(self) -> bool:
FILL_FUNC... | @dataclass
class OpsgenieConfig(BaseConfig):
url: str = None
api_key: str = None
priority: str = "P3"
responders: List[Dict] = field(default_factory=list)
tags: List = field(default_factory=list)
details: Dict = field(default_factory=dict)
@property
def is_valid(self) -> bool:
FILL_FUNC... | return self.url is not None and self.url != 'None'\
and self.api_key is not None and self.api_key != 'None'
| return self.url is not None and self.url != 'None'\
and self.api_key is not None and self.api_key != 'None'
| 18 | 118 | 42 | 160 | from dataclasses import dataclass, field
from mage_ai.shared.config import BaseConfig
from typing import List, Dict
@dataclass
class OpsgenieConfig(BaseConfig):
url: str = None
api_key: str = None
priority: str = "P3"
responders: List[Dict] = field(default_factory=list)
tags: List = field(default_... | from dataclasses import dataclass, field
from mage_ai.shared.config import BaseConfig
from typing import List, Dict
@dataclass
class OpsgenieConfig(BaseConfig):
url: str = None
api_key: str = None
priority: str = "P3"
responders: List[Dict] = field(default_factory=list)
tags: List = field(default_... |
20,678 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/slack/config.py | 9,11 | 5,12 | is_valid | SlackConfig | 11,12 | 11,12 | @dataclass
class SlackConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class SlackConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return self.webhook_url is not None and self.webhook_url != 'None'
| return self.webhook_url is not None and self.webhook_url != 'None'
| 9 | 52 | 25 | 77 | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class SlackConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class SlackConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY |
20,679 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/api/aws_emr.py | 17,19 | 6,39 | spark_ui_url | AwsEmrAPI | 19,35 | 19,35 | class AwsEmrAPI(LocalAPI):
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.application_id:
applications = self.applications_sync()
if applications:
applications = sorted(applications, key=lambda x: x.id, reverse=True)
appl... | class AwsEmrAPI(LocalAPI):
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.application_id:
applications = self.applications_sync()
if applications:
applications = sorted(applications, key=lambda x: x.id, reverse=True)
appl... | url = f'http://{SPARK_UI_HOST}:{SPARK_UI_PORT_AWS_EMR}'
tunnel = SSHTunnel()
if tunnel:
connection_details = tunnel.connection_details()
host = connection_details.get('host')
port = connection_details.get('port')
url = f'http://{host or SPARK_UI_H... | url = f'http://{SPARK_UI_HOST}:{SPARK_UI_PORT_AWS_EMR}'
tunnel = SSHTunnel()
if tunnel:
connection_details = tunnel.connection_details()
host = connection_details.get('host')
port = connection_details.get('port')
url = f'http://{host or SPARK_UI_H... | 36 | 180 | 200 | 380 | from mage_ai.services.spark.api.constants import SPARK_UI_HOST, SPARK_UI_PORT_AWS_EMR
from mage_ai.services.spark.api.local import LocalAPI
from mage_ai.services.ssh.aws.emr.models import SSHTunnel
class AwsEmrAPI(LocalAPI):
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.app... | from mage_ai.services.spark.api.constants import SPARK_UI_HOST, SPARK_UI_PORT_AWS_EMR
from mage_ai.services.spark.api.local import LocalAPI
from mage_ai.services.ssh.aws.emr.models import SSHTunnel
class AwsEmrAPI(LocalAPI):
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.app... |
20,680 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/api/service.py | 8,17 | 7,35 | build | API | 17,35 | 17,35 | class API:
@classmethod
def build(
self,
all_applications: bool = True,
application_id: str = None,
application_spark_ui_url: str = None,
repo_config=None,
spark_session=None,
) -> BaseAPI:
FILL_FUNC_BODY | class API:
@classmethod
def build(
self,
all_applications: bool = True,
application_id: str = None,
application_spark_ui_url: str = None,
repo_config=None,
spark_session=None,
) -> BaseAPI:
FILL_FUNC_BODY | compute_service = get_compute_service(repo_config, ignore_active_kernel=True)
if ComputeServiceUUID.STANDALONE_CLUSTER == compute_service:
return LocalAPI(
all_applications=all_applications,
spark_session=spark_session,
application_id=applicat... | compute_service = get_compute_service(repo_config, ignore_active_kernel=True)
if ComputeServiceUUID.STANDALONE_CLUSTER == compute_service:
return LocalAPI(
all_applications=all_applications,
spark_session=spark_session,
application_id=applicat... | 30 | 87 | 231 | 318 | from mage_ai.services.spark.api.base import BaseAPI
from mage_ai.services.spark.api.local import LocalAPI
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.spark.utils import get_compute_service
class API:
@classmethod
def build(
self,
all_applications: bool... | from mage_ai.services.spark.api.base import BaseAPI
from mage_ai.services.spark.api.local import LocalAPI
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.spark.utils import get_compute_service
class API:
@classmethod
def build(
self,
all_applications: bool... |
20,681 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/applications.py | 45,47 | 27,116 | load | Application | 47,58 | 47,58 | @dataclass
class Application(BaseSparkModel):
id: str # local-1697360611228
attempts: List[ApplicationAttempt] = None
attempts_count: int = None
name: str = None # my spark app
spark_ui_url: str = None
def __post_init__(self):
if self.attempts and isinstance(self.attempts, list):
... | @dataclass
class Application(BaseSparkModel):
id: str # local-1697360611228
attempts: List[ApplicationAttempt] = None
attempts_count: int = None
name: str = None # my spark app
spark_ui_url: str = None
def __post_init__(self):
if self.attempts and isinstance(self.attempts, list):
... | payload = kwargs.copy() if kwargs else {}
if ComputeServiceUUID.AWS_EMR == get_compute_service(ignore_active_kernel=True):
if payload.get('id'):
parts = urllib.parse.unquote(payload.get('id')).split('/')
if len(parts) >= 2:
payload['id'] =... | payload = kwargs.copy() if kwargs else {}
if ComputeServiceUUID.AWS_EMR == get_compute_service(ignore_active_kernel=True):
if payload.get('id'):
parts = urllib.parse.unquote(payload.get('id')).split('/')
if len(parts) >= 2:
payload['id'] =... | 28 | 755 | 139 | 894 | import json
import os
import urllib.parse
from dataclasses import dataclass
from typing import Dict, List
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.utils import get_compute_service
from mage_ai.shared.hash i... | import json
import os
import urllib.parse
from dataclasses import dataclass
from typing import Dict, List
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.utils import get_compute_service
from mage_ai.shared.hash i... |
20,682 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/base.py | 12,14 | 10,20 | cache_dir_path | BaseSparkModel | 14,20 | 14,20 | @dataclass
class BaseSparkModel(BaseDataClass):
@classmethod
def cache_dir_path(self) -> str:
FILL_FUNC_BODY | @dataclass
class BaseSparkModel(BaseDataClass):
@classmethod
def cache_dir_path(self) -> str:
FILL_FUNC_BODY | repo_config = get_repo_config(repo_path=get_repo_path())
return os.path.join(
repo_config.variables_dir,
SPARK_DIRECTORY_NAME,
)
| repo_config = get_repo_config(repo_path=get_repo_path())
return os.path.join(
repo_config.variables_dir,
SPARK_DIRECTORY_NAME,
)
| 8 | 46 | 64 | 110 | import os
from dataclasses import dataclass
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.services.spark.constants import SPARK_DIRECTORY_NAME
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.models import BaseDataClass
@dataclass
class BaseSparkModel(BaseDataClass... | import os
from dataclasses import dataclass
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.services.spark.constants import SPARK_DIRECTORY_NAME
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.models import BaseDataClass
@dataclass
class BaseSparkModel(BaseDataClass... |
20,683 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/jobs.py | 49,51 | 15,52 | id | Job | 51,52 | 51,52 | @dataclass
class Job(BaseSparkModel):
application: Application = None
completion_time: str = None # 2023-10-15T10:17:00.772GMT
job_id: str = None # 54
job_tags: List[str] = field(default_factory=list)
killed_tasks_summary: Dict = field(default_factory=dict)
name: str = None # count at NativeM... | @dataclass
class Job(BaseSparkModel):
application: Application = None
completion_time: str = None # 2023-10-15T10:17:00.772GMT
job_id: str = None # 54
job_tags: List[str] = field(default_factory=list)
killed_tasks_summary: Dict = field(default_factory=dict)
name: str = None # count at NativeM... | return self.job_id
| return self.job_id
| 2 | 510 | 9 | 519 | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
class JobStatus(str, Enum):
FAILED = 'FAILED'
RUNNING = 'RUNNING'
SUCCEEDED = 'SUCC... | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
class JobStatus(str, Enum):
FAILED = 'FAILED'
RUNNING = 'RUNNING'
SUCCEEDED = 'SUCC... |
20,684 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/sqls.py | 44,46 | 27,49 | id | Node | 46,49 | 46,49 | @dataclass
class Node(BaseSparkModel):
metrics: List[Metric] = field(default_factory=list)
node_id: int = None # 13
node_name: str = None # AQEShuffleRead
whole_stage_codegen_id: int = None # 2
def __post_init__(self):
if self.metrics and isinstance(self.metrics, list):
arr =... | @dataclass
class Node(BaseSparkModel):
metrics: List[Metric] = field(default_factory=list)
node_id: int = None # 13
node_name: str = None # AQEShuffleRead
whole_stage_codegen_id: int = None # 2
def __post_init__(self):
if self.metrics and isinstance(self.metrics, list):
arr =... | return self.node_id
| return self.node_id
| 2 | 198 | 13 | 211 | from dataclasses import dataclass, field
from enum import Enum
from typing import List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.jobs import Job
from mage_ai.services.spark.models.stages import Sta... | from dataclasses import dataclass, field
from enum import Enum
from typing import List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.jobs import Job
from mage_ai.services.spark.models.stages import Sta... |
20,685 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/stages.py | 504,506 | 412,509 | id | StageAttempt | 506,509 | 506,509 | @dataclass
class StageAttempt(StageBase):
accumulator_updates: List[str] = field(default_factory=list) # []
attempt_id: int = None # 0
completion_time: str = None # "2023-10-15T10:17:00.772GMT"
# org.apache.spark.sql.Dataset.count(Dataset.scala:3625)
# java.base/jdk.internal.reflect.NativeMethodA... | @dataclass
class StageAttempt(StageBase):
accumulator_updates: List[str] = field(default_factory=list) # []
attempt_id: int = None # 0
completion_time: str = None # "2023-10-15T10:17:00.772GMT"
# org.apache.spark.sql.Dataset.count(Dataset.scala:3625)
# java.base/jdk.internal.reflect.NativeMethodA... | return self.attempt_id
| return self.attempt_id
| 2 | 1,669 | 14 | 1,683 | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... |
20,686 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/stages.py | 407,409 | 295,412 | id | StageBase | 409,412 | 409,412 | @dataclass
class StageBase(BaseSparkModel):
accumulator_updates: List[str] = field(default_factory=list) # []
application: Application = None
attempt_id: int = None # 0
completion_time: str = None # "2023-10-15T10:17:00.772GMT"
# org.apache.spark.sql.Dataset.count(Dataset.scala:3625)
# java.b... | @dataclass
class StageBase(BaseSparkModel):
accumulator_updates: List[str] = field(default_factory=list) # []
application: Application = None
attempt_id: int = None # 0
completion_time: str = None # "2023-10-15T10:17:00.772GMT"
# org.apache.spark.sql.Dataset.count(Dataset.scala:3625)
# java.b... | return self.stage_id
| return self.stage_id
| 2 | 1,914 | 13 | 1,927 | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... |
20,687 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/models/stages.py | 290,292 | 253,295 | id | Task | 292,295 | 292,295 | @dataclass
class Task(BaseSparkModel):
accumulator_updates: int = None # []
attempt: int = None # 0
duration: int = None # 11
executor_id: str = None # "driver"
executor_logs: Dict = field(default_factory=dict) # {}
getting_result_time: int = None # 0
host: str = None # "fecb8bf9abfc"... | @dataclass
class Task(BaseSparkModel):
accumulator_updates: int = None # []
attempt: int = None # 0
duration: int = None # 11
executor_id: str = None # "driver"
executor_logs: Dict = field(default_factory=dict) # {}
getting_result_time: int = None # 0
host: str = None # "fecb8bf9abfc"... | return self.task_id
| return self.task_id
| 2 | 501 | 13 | 514 | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... | from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, List
from mage_ai.services.spark.models.applications import Application
from mage_ai.services.spark.models.base import BaseSparkModel
from mage_ai.services.spark.models.metrics import Metrics
class Locality(str, Enum):
NODE_L... |
20,688 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/spark/utils.py | 9,15 | 1,38 | get_compute_service | 15,38 | 15,38 | from typing import Dict
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.server.kernels import KernelName
from mage_ai.services.spark.constants import ComputeServiceUUID, SparkMaster
from mage_ai.shared.utils import is_spark_env
def get_compute_service(
emr_config: Dict = None,
... | from typing import Dict
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.server.kernels import KernelName
from mage_ai.services.spark.constants import ComputeServiceUUID, SparkMaster
from mage_ai.shared.utils import is_spark_env
def get_compute_service(
emr_config: Dict = None,
... | if not repo_config:
repo_config = get_repo_config()
if repo_config and emr_config:
repo_config.emr_config = emr_config
if not repo_config:
# This is probably happening because there is no repo config in Spark EMR
return None
if not kernel_name:
from mage_ai.ser... | if not repo_config:
repo_config = get_repo_config()
if repo_config and emr_config:
repo_config.emr_config = emr_config
if not repo_config:
# This is probably happening because there is no repo config in Spark EMR
return None
if not kernel_name:
from mage_ai.ser... | 65 | 155 | 263 | 418 | from typing import Dict
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.server.kernels import KernelName
from mage_ai.services.spark.constants import ComputeServiceUUID, SparkMaster
from mage_ai.shared.utils import is_spark_env
def get_compute_service(
emr_config: Dict = None,
... | from typing import Dict
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.server.kernels import KernelName
from mage_ai.services.spark.constants import ComputeServiceUUID, SparkMaster
from mage_ai.shared.utils import is_spark_env
def get_compute_service(
emr_config: Dict = None,
... | |
20,689 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/teams/config.py | 9,11 | 5,12 | is_valid | TeamsConfig | 11,12 | 11,12 | @dataclass
class TeamsConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class TeamsConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return self.webhook_url is not None and self.webhook_url != 'None'
| return self.webhook_url is not None and self.webhook_url != 'None'
| 9 | 52 | 25 | 77 | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class TeamsConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class TeamsConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY |
20,690 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/services/telegram/config.py | 10,12 | 6,13 | is_valid | TelegramConfig | 12,13 | 12,13 | @dataclass
class TelegramConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | @dataclass
class TelegramConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | return self.webhook_url is not None and self.webhook_url != 'None'
| return self.webhook_url is not None and self.webhook_url != 'None'
| 9 | 52 | 25 | 77 | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class TelegramConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY | from dataclasses import dataclass
from mage_ai.shared.config import BaseConfig
@dataclass
class TelegramConfig(BaseConfig):
webhook_url: str = None
@property
def is_valid(self) -> bool:
FILL_FUNC_BODY |
20,691 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/settings/platform/constants.py | 10,11 | 1,30 | platform_settings_full_path | 11,14 | 11,14 | import os
from mage_ai.settings import REQUIRE_USER_AUTHENTICATION
from mage_ai.settings.utils import base_repo_path
PLATFORM_SETTINGS_FILENAME = 'settings.yaml'
LOCAL_PLATFORM_SETTINGS_FILENAME = f'.{PLATFORM_SETTINGS_FILENAME}'
def platform_settings_full_path() -> str:
FILL_FUNC_BODYdef set_project_platform_activ... | import os
from mage_ai.settings import REQUIRE_USER_AUTHENTICATION
from mage_ai.settings.utils import base_repo_path
PLATFORM_SETTINGS_FILENAME = 'settings.yaml'
LOCAL_PLATFORM_SETTINGS_FILENAME = f'.{PLATFORM_SETTINGS_FILENAME}'
def platform_settings_full_path() -> str:
FILL_FUNC_BODYdef set_project_platform_activ... | return os.path.join(base_repo_path(), PLATFORM_SETTINGS_FILENAME)
| return os.path.join(base_repo_path(), PLATFORM_SETTINGS_FILENAME)
| 3 | 268 | 31 | 299 | import os
from mage_ai.settings import REQUIRE_USER_AUTHENTICATION
from mage_ai.settings.utils import base_repo_path
PLATFORM_SETTINGS_FILENAME = 'settings.yaml'
LOCAL_PLATFORM_SETTINGS_FILENAME = f'.{PLATFORM_SETTINGS_FILENAME}'
def platform_settings_full_path() -> str:
FILL_FUNC_BODYdef set_project_platform_activ... | import os
from mage_ai.settings import REQUIRE_USER_AUTHENTICATION
from mage_ai.settings.utils import base_repo_path
PLATFORM_SETTINGS_FILENAME = 'settings.yaml'
LOCAL_PLATFORM_SETTINGS_FILENAME = f'.{PLATFORM_SETTINGS_FILENAME}'
def platform_settings_full_path() -> str:
FILL_FUNC_BODYdef set_project_platform_activ... | |
20,692 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/settings/platform/utils.py | 49,55 | 1,118 | get_pipeline_from_platform_async | 55,79 | 55,79 | import os
from typing import Dict, List, Tuple
from mage_ai.data_preparation.models.constants import (
PIPELINE_CONFIG_FILE,
PIPELINES_FOLDER,
)
from mage_ai.settings.platform import (
build_repo_path_for_all_projects,
get_repo_paths_for_file_path,
project_platform_activated,
repo_path_from_dat... | import os
from typing import Dict, List, Tuple
from mage_ai.data_preparation.models.constants import (
PIPELINE_CONFIG_FILE,
PIPELINES_FOLDER,
)
from mage_ai.settings.platform import (
build_repo_path_for_all_projects,
get_repo_paths_for_file_path,
project_platform_activated,
repo_path_from_dat... | from mage_ai.data_preparation.models.pipeline import Pipeline
if not project_platform_activated():
return await Pipeline.get_async(pipeline_uuid, repo_path=repo_path)
if not mapping:
mapping = repo_path_from_database_query_to_project_repo_path(
'pipeline_schedules',
... | from mage_ai.data_preparation.models.pipeline import Pipeline
if not project_platform_activated():
return await Pipeline.get_async(pipeline_uuid, repo_path=repo_path)
if not mapping:
mapping = repo_path_from_database_query_to_project_repo_path(
'pipeline_schedules',
... | 51 | 950 | 250 | 1,200 | import os
from typing import Dict, List, Tuple
from mage_ai.data_preparation.models.constants import (
PIPELINE_CONFIG_FILE,
PIPELINES_FOLDER,
)
from mage_ai.settings.platform import (
build_repo_path_for_all_projects,
get_repo_paths_for_file_path,
project_platform_activated,
repo_path_from_dat... | import os
from typing import Dict, List, Tuple
from mage_ai.data_preparation.models.constants import (
PIPELINE_CONFIG_FILE,
PIPELINES_FOLDER,
)
from mage_ai.settings.platform import (
build_repo_path_for_all_projects,
get_repo_paths_for_file_path,
project_platform_activated,
repo_path_from_dat... | |
20,693 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/settings/secret_generation.py | 5,6 | 1,8 | generate_jwt_secret | 6,8 | 6,8 | import secrets
import string
def generate_jwt_secret(length=64):
FILL_FUNC_BODY | import secrets
import string
def generate_jwt_secret(length=64):
FILL_FUNC_BODY | characters = string.ascii_letters + string.digits
return ''.join(secrets.choice(characters) for _ in range(length))
| characters = string.ascii_letters + string.digits
return ''.join(secrets.choice(characters) for _ in range(length))
| 11 | 32 | 42 | 74 | import secrets
import string
def generate_jwt_secret(length=64):
FILL_FUNC_BODY | import secrets
import string
def generate_jwt_secret(length=64):
FILL_FUNC_BODY | |
20,695 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/settings/utils.py | 6,7 | 1,16 | base_repo_path | 7,10 | 7,10 | import os
from mage_ai.settings.constants import REPO_PATH_ENV_VAR
def base_repo_path() -> str:
FILL_FUNC_BODYdef base_repo_dirname() -> str:
return os.path.dirname(base_repo_path())
def base_repo_name() -> str:
return os.path.basename(base_repo_path())
| import os
from mage_ai.settings.constants import REPO_PATH_ENV_VAR
def base_repo_path() -> str:
FILL_FUNC_BODYdef base_repo_dirname() -> str:
return os.path.dirname(base_repo_path())
def base_repo_name() -> str:
return os.path.basename(base_repo_path())
| return os.getenv(REPO_PATH_ENV_VAR) or os.getcwd()
| return os.getenv(REPO_PATH_ENV_VAR) or os.getcwd()
| 4 | 107 | 29 | 136 | import os
from mage_ai.settings.constants import REPO_PATH_ENV_VAR
def base_repo_path() -> str:
FILL_FUNC_BODYdef base_repo_dirname() -> str:
return os.path.dirname(base_repo_path())
def base_repo_name() -> str:
return os.path.basename(base_repo_path())
| import os
from mage_ai.settings.constants import REPO_PATH_ENV_VAR
def base_repo_path() -> str:
FILL_FUNC_BODYdef base_repo_dirname() -> str:
return os.path.dirname(base_repo_path())
def base_repo_name() -> str:
return os.path.basename(base_repo_path())
| |
20,696 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/array.py | 16,17 | 1,53 | flatten | 17,20 | 17,20 | import random
def batch(iterable, n=1):
length = len(iterable)
for ndx in range(0, length, n):
yield iterable[ndx:min(ndx + n, length)]
def difference(li1, li2):
li1_lookup = set(li1)
li2_lookup = set(li2)
return [i for i in li1 + li2 if i not in li1_lookup or i not in li2_lookup]
def ... | import random
def batch(iterable, n=1):
length = len(iterable)
for ndx in range(0, length, n):
yield iterable[ndx:min(ndx + n, length)]
def difference(li1, li2):
li1_lookup = set(li1)
li2_lookup = set(li2)
return [i for i in li1 + li2 if i not in li1_lookup or i not in li2_lookup]
def ... | return [item for sublist in arr for item in sublist]
| return [item for sublist in arr for item in sublist]
| 10 | 378 | 21 | 399 | import random
def batch(iterable, n=1):
length = len(iterable)
for ndx in range(0, length, n):
yield iterable[ndx:min(ndx + n, length)]
def difference(li1, li2):
li1_lookup = set(li1)
li2_lookup = set(li2)
return [i for i in li1 + li2 if i not in li1_lookup or i not in li2_lookup]
def ... | import random
def batch(iterable, n=1):
length = len(iterable)
for ndx in range(0, length, n):
yield iterable[ndx:min(ndx + n, length)]
def difference(li1, li2):
li1_lookup = set(li1)
li2_lookup = set(li2)
return [i for i in li1 + li2 if i not in li1_lookup or i not in li2_lookup]
def ... | |
20,697 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/code.py | 1,2 | 1,3 | is_pyspark_code | 2,3 | 2,3 | def is_pyspark_code(code: str):
FILL_FUNC_BODY | def is_pyspark_code(code: str):
FILL_FUNC_BODY | return '\'spark\'' in code or '"spark"' in code
| return '\'spark\'' in code or '"spark"' in code
| 8 | 24 | 19 | 43 | def is_pyspark_code(code: str):
FILL_FUNC_BODY | def is_pyspark_code(code: str):
FILL_FUNC_BODY | |
20,698 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/custom_types.py | 14,15 | 4,32 | pop | FrozenDict | 15,17 | 15,17 | class FrozenDict(dict):
def __setitem__(self, __k, __v) -> None:
raise AttributeError('Cannot assign a value to frozen dictionary')
def __delitem__(self, __v) -> None:
raise AttributeError('Cannot delete a value from frozen dictionary')
def clear(self) -> None:
raise AttributeError... | class FrozenDict(dict):
def __setitem__(self, __k, __v) -> None:
raise AttributeError('Cannot assign a value to frozen dictionary')
def __delitem__(self, __v) -> None:
raise AttributeError('Cannot delete a value from frozen dictionary')
def clear(self) -> None:
raise AttributeError... | raise AttributeError('Cannot remove item from a frozen dictionary')
| raise AttributeError('Cannot remove item from a frozen dictionary')
| 8 | 284 | 18 | 302 | from typing import Any
class FrozenDict(dict):
def __setitem__(self, __k, __v) -> None:
raise AttributeError('Cannot assign a value to frozen dictionary')
def __delitem__(self, __v) -> None:
raise AttributeError('Cannot delete a value from frozen dictionary')
def clear(self) -> None:
... | from typing import Any
class FrozenDict(dict):
def __setitem__(self, __k, __v) -> None:
raise AttributeError('Cannot assign a value to frozen dictionary')
def __delitem__(self, __v) -> None:
raise AttributeError('Cannot delete a value from frozen dictionary')
def clear(self) -> None:
... |
20,699 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/environments.py | 11,12 | 1,40 | is_debug | 12,15 | 12,15 | import os
import sys
from mage_ai.shared.constants import ENV_DEV, ENV_PROD, ENV_STAGING, ENV_TEST
def is_deus_ex_machina():
return int(os.getenv('DEUS_EX_MACHINA', 0) or 0) == 1
def is_debug():
FILL_FUNC_BODYdef is_dev():
return os.getenv('ENV', None) == 'dev' or os.getenv('ENV', None) == 'development'
... | import os
import sys
from mage_ai.shared.constants import ENV_DEV, ENV_PROD, ENV_STAGING, ENV_TEST
def is_deus_ex_machina():
return int(os.getenv('DEUS_EX_MACHINA', 0) or 0) == 1
def is_debug():
FILL_FUNC_BODYdef is_dev():
return os.getenv('ENV', None) == 'dev' or os.getenv('ENV', None) == 'development'
... | return int(os.getenv('DEBUG', 0) or 0) == 1
| return int(os.getenv('DEBUG', 0) or 0) == 1
| 7 | 311 | 26 | 337 | import os
import sys
from mage_ai.shared.constants import ENV_DEV, ENV_PROD, ENV_STAGING, ENV_TEST
def is_deus_ex_machina():
return int(os.getenv('DEUS_EX_MACHINA', 0) or 0) == 1
def is_debug():
FILL_FUNC_BODYdef is_dev():
return os.getenv('ENV', None) == 'dev' or os.getenv('ENV', None) == 'development'
... | import os
import sys
from mage_ai.shared.constants import ENV_DEV, ENV_PROD, ENV_STAGING, ENV_TEST
def is_deus_ex_machina():
return int(os.getenv('DEUS_EX_MACHINA', 0) or 0) == 1
def is_debug():
FILL_FUNC_BODYdef is_dev():
return os.getenv('ENV', None) == 'dev' or os.getenv('ENV', None) == 'development'
... | |
20,700 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/hash.py | 45,46 | 1,224 | safe_dig | 58,91 | 46,91 | import json
import math
import re
from functools import reduce
from typing import Any, Dict, List
from mage_ai.shared.strings import camel_to_snake_case
def camel_case_keys_to_snake_case(d):
if not isinstance(d, dict):
return d
snake_dict = {}
for key, value in d.items():
snake_key = came... | import json
import math
import re
from functools import reduce
from typing import Any, Dict, List
from mage_ai.shared.strings import camel_to_snake_case
def camel_case_keys_to_snake_case(d):
if not isinstance(d, dict):
return d
snake_dict = {}
for key, value in d.items():
snake_key = came... | if isinstance(arr_or_string, str):
arr_or_string = arr_or_string.split('.')
arr = list(map(str.strip, arr_or_string))
def _build(obj, key):
# Return None if the object is None or not a dictionary
if obj is None or not isinstance(obj, dict) and not isinstance(obj, list):
... | """
Safely retrieves nested values from a dictionary or list using a dot-separated path.
Args:
obj_arg: The object (dictionary or list) to navigate.
arr_or_string (str or list): A dot-separated path string or a list of
keys/indexes.
Returns:
The value retrieved from... | 127 | 1,633 | 349 | 1,982 | import json
import math
import re
from functools import reduce
from typing import Any, Dict, List
from mage_ai.shared.strings import camel_to_snake_case
def camel_case_keys_to_snake_case(d):
if not isinstance(d, dict):
return d
snake_dict = {}
for key, value in d.items():
snake_key = came... | import json
import math
import re
from functools import reduce
from typing import Any, Dict, List
from mage_ai.shared.strings import camel_to_snake_case
def camel_case_keys_to_snake_case(d):
if not isinstance(d, dict):
return d
snake_dict = {}
for key, value in d.items():
snake_key = came... | |
20,701 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/logger.py | 87,88 | 1,190 | set_logging_format | 88,110 | 88,110 | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | if isinstance(logging_format, str):
logging_format = logging_format.lower()
root_logger = logging.getLogger()
if len(root_logger.handlers) > 0:
root_logger.removeHandler(root_logger.handlers[0])
handler = logging.StreamHandler()
if logging_format == 'json':
handler.setForma... | if isinstance(logging_format, str):
logging_format = logging_format.lower()
root_logger = logging.getLogger()
if len(root_logger.handlers) > 0:
root_logger.removeHandler(root_logger.handlers[0])
handler = logging.StreamHandler()
if logging_format == 'json':
handler.setForma... | 38 | 1,489 | 224 | 1,713 | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | |
20,702 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/logger.py | 57,58 | 41,87 | format | JSONFormatter | 58,87 | 58,87 | class JSONFormatter(logging.Formatter):
def __init__(
self,
fmt=None,
datefmt=None,
style='%',
additional_json_fields: List[str] = None,
):
super().__init__(fmt, datefmt, style)
if additional_json_fields is None:
additional_json_fields = []
... | class JSONFormatter(logging.Formatter):
def __init__(
self,
fmt=None,
datefmt=None,
style='%',
additional_json_fields: List[str] = None,
):
super().__init__(fmt, datefmt, style)
if additional_json_fields is None:
additional_json_fields = []
... | super().format(record)
# Baseline fields for all JSON log messages
log_data = {
'timestamp': record.asctime,
'level': record.levelname,
'message': record.getMessage(),
'logger': record.name,
'module': record.module,
'functio... | super().format(record)
# Baseline fields for all JSON log messages
log_data = {
'timestamp': record.asctime,
'level': record.levelname,
'message': record.getMessage(),
'logger': record.name,
'module': record.module,
'functio... | 97 | 155 | 320 | 475 | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... |
20,703 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/logger.py | 117,119 | 110,122 | is_valid_level | LoggingLevel | 119,122 | 119,122 | class LoggingLevel(str, Enum):
DEBUG = 'DEBUG'
INFO = 'INFO'
WARNING = 'WARNING'
ERROR = 'ERROR'
CRITICAL = 'CRITICAL'
@classmethod
def is_valid_level(cls, level: str) -> bool:
FILL_FUNC_BODY | class LoggingLevel(str, Enum):
DEBUG = 'DEBUG'
INFO = 'INFO'
WARNING = 'WARNING'
ERROR = 'ERROR'
CRITICAL = 'CRITICAL'
@classmethod
def is_valid_level(cls, level: str) -> bool:
FILL_FUNC_BODY | return level.upper() in cls.__members__
| return level.upper() in cls.__members__
| 4 | 87 | 18 | 105 | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... |
20,704 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/logger.py | 153,155 | 146,165 | print_msg | VerbosePrintHandler | 155,165 | 155,165 | class VerbosePrintHandler:
def __init__(self, start_msg, verbose=False):
self.verbose = verbose
if verbose:
print(start_msg)
self.exists_previous_message = False
@contextmanager
def print_msg(self, msg):
FILL_FUNC_BODY | class VerbosePrintHandler:
def __init__(self, start_msg, verbose=False):
self.verbose = verbose
if verbose:
print(start_msg)
self.exists_previous_message = False
@contextmanager
def print_msg(self, msg):
FILL_FUNC_BODY | if self.verbose:
if self.exists_previous_message:
print('\r├─ ')
print(f'└─ {msg}...', end='')
yield msg
if self.verbose:
print('DONE', end='')
self.exists_previous_message = True
| if self.verbose:
if self.exists_previous_message:
print('\r├─ ')
print(f'└─ {msg}...', end='')
yield msg
if self.verbose:
print('DONE', end='')
self.exists_previous_message = True
| 18 | 86 | 93 | 179 | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... | import json
import logging
import time
from contextlib import contextmanager, redirect_stdout
from enum import Enum
from typing import Callable, List
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
from mage_ai.shared.hash import merge_dict
logger = logging.getLogger(__name__)
class timer(object):
"""
... |
20,705 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/path_fixer.py | 81,82 | 1,169 | remove_base_repo_name | 87,94 | 82,94 | import os
from pathlib import Path
from typing import Tuple
from mage_ai.settings.platform import get_repo_paths_for_file_path
from mage_ai.settings.repo import get_repo_path
from mage_ai.settings.utils import base_repo_dirname, base_repo_name, base_repo_path
from mage_ai.shared.files import find_directory
def add_a... | import os
from pathlib import Path
from typing import Tuple
from mage_ai.settings.platform import get_repo_paths_for_file_path
from mage_ai.settings.repo import get_repo_path
from mage_ai.settings.utils import base_repo_dirname, base_repo_name, base_repo_path
from mage_ai.shared.files import find_directory
def add_a... | try:
path = Path(file_path).relative_to(base_repo_name())
return str(path)
except ValueError:
return file_path
| """
Removes default_platform from
default_platform/dbt/demo == dbt/demo
default_platform/default_repo/dbt/demo == default_repo/dbt/demo
"""
try:
path = Path(file_path).relative_to(base_repo_name())
return str(path)
except ValueError:
return file_path
| 10 | 1,654 | 52 | 1,706 | import os
from pathlib import Path
from typing import Tuple
from mage_ai.settings.platform import get_repo_paths_for_file_path
from mage_ai.settings.repo import get_repo_path
from mage_ai.settings.utils import base_repo_dirname, base_repo_name, base_repo_path
from mage_ai.shared.files import find_directory
def add_a... | import os
from pathlib import Path
from typing import Tuple
from mage_ai.settings.platform import get_repo_paths_for_file_path
from mage_ai.settings.repo import get_repo_path
from mage_ai.settings.utils import base_repo_dirname, base_repo_name, base_repo_path
from mage_ai.shared.files import find_directory
def add_a... | |
20,706 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/requests.py | 6,7 | 1,29 | get_bearer_auth_token_from_headers | 14,29 | 7,29 | from typing import Dict, Optional
from mage_ai.shared.array import find
def get_bearer_auth_token_from_headers(headers: Dict) -> Optional[str]:
FILL_FUNC_BODY | from typing import Dict, Optional
from mage_ai.shared.array import find
def get_bearer_auth_token_from_headers(headers: Dict) -> Optional[str]:
"""
Args:
headers (Dict): Headers from the request
Returns:
Optional[str]: The bearer token from the headers if it exists
"""
FILL_FUNC_BODY | if headers is None:
return None
token_from_header = headers.get('Authorization')
if token_from_header:
tokens = token_from_header.split(',')
token_from_header = find(lambda x: 'bearer' in x.lower(), tokens)
if token_from_header:
token_from_header = (
... | """
Args:
headers (Dict): Headers from the request
Returns:
Optional[str]: The bearer token from the headers if it exists
"""
if headers is None:
return None
token_from_header = headers.get('Authorization')
if token_from_header:
tokens = token_from_header.spl... | 41 | 103 | 156 | 259 | from typing import Dict, Optional
from mage_ai.shared.array import find
def get_bearer_auth_token_from_headers(headers: Dict) -> Optional[str]:
FILL_FUNC_BODY | from typing import Dict, Optional
from mage_ai.shared.array import find
def get_bearer_auth_token_from_headers(headers: Dict) -> Optional[str]:
"""
Args:
headers (Dict): Headers from the request
Returns:
Optional[str]: The bearer token from the headers if it exists
"""
FILL_FUNC_BODY | |
20,707 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/retry.py | 5,14 | 1,62 | retry | 24,62 | 14,62 | import time
from typing import Dict
def retry(
retries: int = 2,
delay: int = 5,
max_delay: int = 60,
exponential_backoff: bool = True,
logger=None,
logging_tags: Dict = None,
retry_metadata: Dict = None,
):
FILL_FUNC_BODY | import time
from typing import Dict
def retry(
retries: int = 2,
delay: int = 5,
max_delay: int = 60,
exponential_backoff: bool = True,
logger=None,
logging_tags: Dict = None,
retry_metadata: Dict = None,
):
"""
Create the decorator to retry a method
Args:
retries (int... | if logging_tags is None:
logging_tags = dict()
def retry_decorator(func):
def retry_func(*args, **kwargs):
max_attempts = retries + 1
attempt = 1
total_delay = 0
curr_delay = delay
while attempt <= max_attempts:
try:
... | """
Create the decorator to retry a method
Args:
retries (int, optional): Number of retry attempts.
delay (int, optional): Delay between retries. If using exponential backoff retry,
delay will be multiplied by 2 for each additional retry.
max_delay (int, optional): Maxim... | 118 | 207 | 388 | 595 | import time
from typing import Dict
def retry(
retries: int = 2,
delay: int = 5,
max_delay: int = 60,
exponential_backoff: bool = True,
logger=None,
logging_tags: Dict = None,
retry_metadata: Dict = None,
):
FILL_FUNC_BODY | import time
from typing import Dict
def retry(
retries: int = 2,
delay: int = 5,
max_delay: int = 60,
exponential_backoff: bool = True,
logger=None,
logging_tags: Dict = None,
retry_metadata: Dict = None,
):
"""
Create the decorator to retry a method
Args:
retries (int... | |
20,708 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/security.py | 14,15 | 1,52 | filter_out_env_var_values | 15,23 | 15,23 | import os
from typing import Dict, List
MIN_SECRET_LENGTH = 8
WHITELISTED_ENV_VARS = set([
'MAGE_DATA_DIR',
'MAGE_REPO_PATH',
'HOME',
'PWD',
'PYTHONPATH',
])
def filter_out_env_var_values(value: str) -> str:
FILL_FUNC_BODYdef filter_out_config_values(log: str, config: Dict) -> str:
"""
Us... | import os
from typing import Dict, List
MIN_SECRET_LENGTH = 8
WHITELISTED_ENV_VARS = set([
'MAGE_DATA_DIR',
'MAGE_REPO_PATH',
'HOME',
'PWD',
'PYTHONPATH',
])
def filter_out_env_var_values(value: str) -> str:
FILL_FUNC_BODYdef filter_out_config_values(log: str, config: Dict) -> str:
"""
Us... | env_var_values = dict(os.environ).values()
whitelisted_env_var_values = set([os.getenv(k) for k in WHITELISTED_ENV_VARS if os.getenv(k)])
env_var_values = [v for v in env_var_values
if v and len(v) >= MIN_SECRET_LENGTH
and v not in whitelisted_env_var_values]
... | env_var_values = dict(os.environ).values()
whitelisted_env_var_values = set([os.getenv(k) for k in WHITELISTED_ENV_VARS if os.getenv(k)])
env_var_values = [v for v in env_var_values
if v and len(v) >= MIN_SECRET_LENGTH
and v not in whitelisted_env_var_values]
... | 33 | 412 | 139 | 551 | import os
from typing import Dict, List
MIN_SECRET_LENGTH = 8
WHITELISTED_ENV_VARS = set([
'MAGE_DATA_DIR',
'MAGE_REPO_PATH',
'HOME',
'PWD',
'PYTHONPATH',
])
def filter_out_env_var_values(value: str) -> str:
FILL_FUNC_BODYdef filter_out_config_values(log: str, config: Dict) -> str:
"""
Us... | import os
from typing import Dict, List
MIN_SECRET_LENGTH = 8
WHITELISTED_ENV_VARS = set([
'MAGE_DATA_DIR',
'MAGE_REPO_PATH',
'HOME',
'PWD',
'PYTHONPATH',
])
def filter_out_env_var_values(value: str) -> str:
FILL_FUNC_BODYdef filter_out_config_values(log: str, config: Dict) -> str:
"""
Us... | |
20,709 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/urls.py | 6,7 | 1,18 | s3_url_path | 7,13 | 7,13 | from urllib.parse import urlparse
from mage_ai.shared.constants import GCS_PREFIX, S3_PREFIX
def s3_url_path(path):
FILL_FUNC_BODYdef gcs_url_path(path):
if path.startswith(GCS_PREFIX):
gcs_url = urlparse(path, allow_fragments=False)
return gcs_url.path.lstrip('/')
return path
| from urllib.parse import urlparse
from mage_ai.shared.constants import GCS_PREFIX, S3_PREFIX
def s3_url_path(path):
FILL_FUNC_BODYdef gcs_url_path(path):
if path.startswith(GCS_PREFIX):
gcs_url = urlparse(path, allow_fragments=False)
return gcs_url.path.lstrip('/')
return path
| if path.startswith(S3_PREFIX):
s3_url = urlparse(path, allow_fragments=False)
return s3_url.path.lstrip('/')
return path
| if path.startswith(S3_PREFIX):
s3_url = urlparse(path, allow_fragments=False)
return s3_url.path.lstrip('/')
return path
| 10 | 120 | 60 | 180 | from urllib.parse import urlparse
from mage_ai.shared.constants import GCS_PREFIX, S3_PREFIX
def s3_url_path(path):
FILL_FUNC_BODYdef gcs_url_path(path):
if path.startswith(GCS_PREFIX):
gcs_url = urlparse(path, allow_fragments=False)
return gcs_url.path.lstrip('/')
return path
| from urllib.parse import urlparse
from mage_ai.shared.constants import GCS_PREFIX, S3_PREFIX
def s3_url_path(path):
FILL_FUNC_BODYdef gcs_url_path(path):
if path.startswith(GCS_PREFIX):
gcs_url = urlparse(path, allow_fragments=False)
return gcs_url.path.lstrip('/')
return path
| |
20,710 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/shared/utils.py | 103,104 | 1,178 | convert_python_type_to_redshift_type | 104,115 | 104,115 | import os
import re
import socket
from datetime import datetime
from pathlib import Path
from typing import Dict, List
from mage_ai.shared.strings import replacer
def clean_name(
name,
allow_characters: List[str] = None,
allow_number: bool = False,
case_sensitive: bool = False,
):
"""
Clean a... | import os
import re
import socket
from datetime import datetime
from pathlib import Path
from typing import Dict, List
from mage_ai.shared.strings import replacer
def clean_name(
name,
allow_characters: List[str] = None,
allow_number: bool = False,
case_sensitive: bool = False,
):
"""
Clean a... | if python_type is int:
return 'BIGINT'
elif python_type is float:
return 'FLOAT8'
elif python_type is bool:
return 'BOOLEAN'
elif python_type is datetime:
return 'TIMESTAMP'
return 'VARCHAR'
| if python_type is int:
return 'BIGINT'
elif python_type is float:
return 'FLOAT8'
elif python_type is bool:
return 'BOOLEAN'
elif python_type is datetime:
return 'TIMESTAMP'
return 'VARCHAR'
| 26 | 1,534 | 90 | 1,624 | import os
import re
import socket
from datetime import datetime
from pathlib import Path
from typing import Dict, List
from mage_ai.shared.strings import replacer
def clean_name(
name,
allow_characters: List[str] = None,
allow_number: bool = False,
case_sensitive: bool = False,
):
"""
Clean a... | import os
import re
import socket
from datetime import datetime
from pathlib import Path
from typing import Dict, List
from mage_ai.shared.strings import replacer
def clean_name(
name,
allow_characters: List[str] = None,
allow_number: bool = False,
case_sensitive: bool = False,
):
"""
Clean a... | |
20,711 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/streaming/sinks/base.py | 66,67 | 11,116 | has_buffer_timed_out | BaseSink | 67,74 | 67,74 | class BaseSink(ABC):
config_class = None
def __init__(self, config: Dict, **kwargs):
self.connector_type = config.get('connector_type')
if self.config_class is not None:
if 'connector_type' in config:
config.pop('connector_type')
self.config = self.config... | class BaseSink(ABC):
config_class = None
def __init__(self, config: Dict, **kwargs):
self.connector_type = config.get('connector_type')
if self.config_class is not None:
if 'connector_type' in config:
config.pop('connector_type')
self.config = self.config... | if self.buffer_start_time is None:
return False
if buffer_timeout_seconds <= 0:
return False
return (datetime.now(timezone.utc) -
self.buffer_start_time).total_seconds() >= buffer_timeout_seconds
| if self.buffer_start_time is None:
return False
if buffer_timeout_seconds <= 0:
return False
return (datetime.now(timezone.utc) -
self.buffer_start_time).total_seconds() >= buffer_timeout_seconds
| 18 | 879 | 75 | 954 | import json
import os
import traceback
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import Dict, List
MESSAGE_FORMAT_V2_KEYS = frozenset(['data', 'metadata'])
class BaseSink(ABC):
config_class = None
def __init__(self, config: Dict, **kwargs):
self.connecto... | import json
import os
import traceback
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import Dict, List
MESSAGE_FORMAT_V2_KEYS = frozenset(['data', 'metadata'])
class BaseSink(ABC):
config_class = None
def __init__(self, config: Dict, **kwargs):
self.connecto... |
20,712 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/streaming/sinks/dummy.py | 20,21 | 14,30 | write | DummySink | 21,24 | 21,24 | class DummySink(BaseSink):
config_class = DummyConfig
def init_client(self):
pass
def write(self, message: Dict):
FILL_FUNC_BODY def batch_write(self, messages: List[Dict]):
if not messages:
return
if self.config.print_msg:
self._print(
f'... | class DummySink(BaseSink):
config_class = DummyConfig
def init_client(self):
pass
def write(self, message: Dict):
FILL_FUNC_BODY def batch_write(self, messages: List[Dict]):
if not messages:
return
if self.config.print_msg:
self._print(
f'... | if self.config.print_msg:
self._print(f'Ingest data {message}, time={time.time()}')
| if self.config.print_msg:
self._print(f'Ingest data {message}, time={time.time()}')
| 6 | 129 | 38 | 167 | import time
from dataclasses import dataclass
from typing import Dict, List
from mage_ai.shared.config import BaseConfig
from mage_ai.streaming.sinks.base import BaseSink
@dataclass
class DummyConfig(BaseConfig):
print_msg: bool = True
class DummySink(BaseSink):
config_class = DummyConfig
def init_cli... | import time
from dataclasses import dataclass
from typing import Dict, List
from mage_ai.shared.config import BaseConfig
from mage_ai.streaming.sinks.base import BaseSink
@dataclass
class DummyConfig(BaseConfig):
print_msg: bool = True
class DummySink(BaseSink):
config_class = DummyConfig
def init_cli... |
20,713 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/streaming/sinks/sink_factory.py | 7,9 | 6,81 | get_sink | SinkFactory | 9,81 | 9,81 | class SinkFactory:
@classmethod
def get_sink(self, config: Dict, **kwargs):
FILL_FUNC_BODY | class SinkFactory:
@classmethod
def get_sink(self, config: Dict, **kwargs):
FILL_FUNC_BODY | connector_type = config['connector_type']
if connector_type == SinkType.ACTIVEMQ:
from mage_ai.streaming.sinks.activemq import ActiveMQSink
return ActiveMQSink(config, **kwargs)
elif connector_type == SinkType.AMAZON_S3:
from mage_ai.streaming.sinks.amazon_s3... | connector_type = config['connector_type']
if connector_type == SinkType.ACTIVEMQ:
from mage_ai.streaming.sinks.activemq import ActiveMQSink
return ActiveMQSink(config, **kwargs)
elif connector_type == SinkType.AMAZON_S3:
from mage_ai.streaming.sinks.amazon_s3... | 197 | 39 | 1,031 | 1,070 | from typing import Dict
from mage_ai.streaming.constants import GENERIC_IO_SINK_TYPES, SinkType
class SinkFactory:
@classmethod
def get_sink(self, config: Dict, **kwargs):
FILL_FUNC_BODY | from typing import Dict
from mage_ai.streaming.constants import GENERIC_IO_SINK_TYPES, SinkType
class SinkFactory:
@classmethod
def get_sink(self, config: Dict, **kwargs):
FILL_FUNC_BODY |
20,714 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/streaming/sources/base.py | 51,52 | 15,99 | read_async | BaseSource | 57,60 | 52,60 | class BaseSource(ABC):
config_class = None
consume_method = SourceConsumeMethod.BATCH_READ
def __init__(self, config: Dict, **kwargs):
if self.config_class is not None:
if 'connector_type' in config:
config.pop('connector_type')
self.config = self.config_clas... | class BaseSource(ABC):
config_class = None
consume_method = SourceConsumeMethod.BATCH_READ
def __init__(self, config: Dict, **kwargs):
if self.config_class is not None:
if 'connector_type' in config:
config.pop('connector_type')
self.config = self.config_clas... | self._print('Start consuming messages asynchronously.')
return self.read(handler)
| """
Read the message asynchronously from the source and use handler to process the message.
This method only needs to be implemented when consume_method is 'READ_ASYNC'.
"""
self._print('Start consuming messages asynchronously.')
return self.read(handler)
| 6 | 668 | 27 | 695 | import json
from abc import ABC, abstractmethod
from enum import Enum
from typing import Callable, Dict
from mage_ai.shared.environments import is_test
class SourceConsumeMethod(str, Enum):
BATCH_READ = 'BATCH_READ'
READ = 'READ'
READ_ASYNC = 'READ_ASYNC'
class BaseSource(ABC):
config_class = None
... | import json
from abc import ABC, abstractmethod
from enum import Enum
from typing import Callable, Dict
from mage_ai.shared.environments import is_test
class SourceConsumeMethod(str, Enum):
BATCH_READ = 'BATCH_READ'
READ = 'READ'
READ_ASYNC = 'READ_ASYNC'
class BaseSource(ABC):
config_class = None
... |
20,715 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/streaming/sources/source_factory.py | 8,10 | 7,79 | get_source | SourceFactory | 10,56 | 10,56 | class SourceFactory:
@classmethod
def get_source(self, config: Dict, **kwargs):
FILL_FUNC_BODY @classmethod
def get_python_source(self, content: str, **kwargs):
"""
Find the class that's decorated with streaming_source from the source code.
Args:
content (str): The py... | class SourceFactory:
@classmethod
def get_source(self, config: Dict, **kwargs):
FILL_FUNC_BODY @classmethod
def get_python_source(self, content: str, **kwargs):
"""
Find the class that's decorated with streaming_source from the source code.
Args:
content (str): The py... | connector_type = config['connector_type']
if connector_type == SourceType.AMAZON_SQS:
from mage_ai.streaming.sources.amazon_sqs import AmazonSqsSource
return AmazonSqsSource(config, **kwargs)
elif connector_type == SourceType.AZURE_EVENT_HUB:
from mage_ai.str... | connector_type = config['connector_type']
if connector_type == SourceType.AMAZON_SQS:
from mage_ai.streaming.sources.amazon_sqs import AmazonSqsSource
return AmazonSqsSource(config, **kwargs)
elif connector_type == SourceType.AZURE_EVENT_HUB:
from mage_ai.str... | 129 | 215 | 629 | 844 | from typing import Dict
from mage_ai.data_preparation.decorators import collect_decorated_objs
from mage_ai.streaming.constants import SourceType
class SourceFactory:
@classmethod
def get_source(self, config: Dict, **kwargs):
FILL_FUNC_BODY @classmethod
def get_python_source(self, content: str, **kwar... | from typing import Dict
from mage_ai.data_preparation.decorators import collect_decorated_objs
from mage_ai.streaming.constants import SourceType
class SourceFactory:
@classmethod
def get_source(self, config: Dict, **kwargs):
FILL_FUNC_BODY @classmethod
def get_python_source(self, content: str, **kwar... |
20,716 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/usage_statistics/utils.py | 4,5 | 1,19 | build_event_data_for_chart | 5,19 | 5,19 | from typing import Dict
def build_event_data_for_chart(chart_config: Dict = None) -> Dict:
FILL_FUNC_BODY | from typing import Dict
def build_event_data_for_chart(chart_config: Dict = None) -> Dict:
FILL_FUNC_BODY | if not chart_config:
return {}
data_source = chart_config.get('data_source') or {}
configuration = chart_config.get('configuration') or {}
group_by = configuration.get('group_by')
metrics = configuration.get('metrics')
return dict(
chart_type=configuration.get('chart_type'),
... | if not chart_config:
return {}
data_source = chart_config.get('data_source') or {}
configuration = chart_config.get('configuration') or {}
group_by = configuration.get('group_by')
metrics = configuration.get('metrics')
return dict(
chart_type=configuration.get('chart_type'),
... | 36 | 44 | 156 | 200 | from typing import Dict
def build_event_data_for_chart(chart_config: Dict = None) -> Dict:
FILL_FUNC_BODY | from typing import Dict
def build_event_data_for_chart(chart_config: Dict = None) -> Dict:
FILL_FUNC_BODY | |
20,717 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_ai/utils/code.py | 28,29 | 1,91 | extract_decorated_function | 29,91 | 29,91 | import importlib
import re
from typing import Tuple
from mage_ai.autocomplete.utils import extract_all_imports
from mage_ai.settings.repo import get_repo_path
def reload_all_repo_modules(content: str) -> None:
parts = get_repo_path().split('/')
project_name = parts[-1]
for line in extract_all_imports(co... | import importlib
import re
from typing import Tuple
from mage_ai.autocomplete.utils import extract_all_imports
from mage_ai.settings.repo import get_repo_path
def reload_all_repo_modules(content: str) -> None:
parts = get_repo_path().split('/')
project_name = parts[-1]
for line in extract_all_imports(co... | spans = []
span_current_start = None
span_current_def = None
lines = code.split('\n')
number_of_lines = len(lines)
for idx, line in enumerate(lines):
if line and \
span_current_start is not None and \
span_current_def is not None:
if line.s... | spans = []
span_current_start = None
span_current_def = None
lines = code.split('\n')
number_of_lines = len(lines)
for idx, line in enumerate(lines):
if line and \
span_current_start is not None and \
span_current_def is not None:
if line.s... | 161 | 275 | 555 | 830 | import importlib
import re
from typing import Tuple
from mage_ai.autocomplete.utils import extract_all_imports
from mage_ai.settings.repo import get_repo_path
def reload_all_repo_modules(content: str) -> None:
parts = get_repo_path().split('/')
project_name = parts[-1]
for line in extract_all_imports(co... | import importlib
import re
from typing import Tuple
from mage_ai.autocomplete.utils import extract_all_imports
from mage_ai.settings.repo import get_repo_path
def reload_all_repo_modules(content: str) -> None:
parts = get_repo_path().split('/')
project_name = parts[-1]
for line in extract_all_imports(co... | |
20,718 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/connections/base.py | 15,16 | 4,20 | exception | Connection | 16,18 | 16,18 | class Connection():
def __init__(self, verbose: int = 1, **kwargs):
self.logger = Logger(caller=self, verbose=verbose)
self.verbose = verbose
def build_tags(self, **kwargs):
return self.logger.build_tags(**kwargs)
def error(self, message, tags={}, **kwargs):
self.logger.err... | class Connection():
def __init__(self, verbose: int = 1, **kwargs):
self.logger = Logger(caller=self, verbose=verbose)
self.verbose = verbose
def build_tags(self, **kwargs):
return self.logger.build_tags(**kwargs)
def error(self, message, tags={}, **kwargs):
self.logger.err... | self.logger.exception(message, tags, **kwargs)
| self.logger.exception(message, tags, **kwargs)
| 3 | 168 | 18 | 186 | from mage_integrations.utils.logger import Logger
class Connection():
def __init__(self, verbose: int = 1, **kwargs):
self.logger = Logger(caller=self, verbose=verbose)
self.verbose = verbose
def build_tags(self, **kwargs):
return self.logger.build_tags(**kwargs)
def error(self, ... | from mage_integrations.utils.logger import Logger
class Connection():
def __init__(self, verbose: int = 1, **kwargs):
self.logger = Logger(caller=self, verbose=verbose)
self.verbose = verbose
def build_tags(self, **kwargs):
return self.logger.build_tags(**kwargs)
def error(self, ... |
20,719 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/connections/google_analytics/utils.py | 1,2 | 1,15 | parse_response | 2,15 | 2,15 | def parse_response(request, response):
FILL_FUNC_BODY | def parse_response(request, response):
FILL_FUNC_BODY | dimensions = [i.name for i in request.dimensions]
metrics = [i.name for i in request.metrics]
arr = []
for row in response.rows:
data = dict()
for idx, dimension in enumerate(dimensions):
data[dimension] = row.dimension_values[idx].value
for idx, metric in enumerate(... | dimensions = [i.name for i in request.dimensions]
metrics = [i.name for i in request.metrics]
arr = []
for row in response.rows:
data = dict()
for idx, dimension in enumerate(dimensions):
data[dimension] = row.dimension_values[idx].value
for idx, metric in enumerate(... | 43 | 20 | 139 | 159 | def parse_response(request, response):
FILL_FUNC_BODY | def parse_response(request, response):
FILL_FUNC_BODY | |
20,720 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/connections/utils/sql.py | 1,2 | 1,3 | clean_query | 2,3 | 2,3 | def clean_query(query_string: str) -> str:
FILL_FUNC_BODY | def clean_query(query_string: str) -> str:
FILL_FUNC_BODY | return query_string.strip(' \n\t')
| return query_string.strip(' \n\t')
| 3 | 26 | 15 | 41 | def clean_query(query_string: str) -> str:
FILL_FUNC_BODY | def clean_query(query_string: str) -> str:
FILL_FUNC_BODY | |
20,721 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/delta_lake/raw_delta_table.py | 13,14 | 1,15 | create_write_transaction | RawDeltaTable | 14,15 | 14,15 | class RawDeltaTable():
def __init__(self, raw_delta_table):
self._table = raw_delta_table
self.schema = self._table.schema
self.version = self._table.version
def table_uri(self):
return self._table.table_uri()
def protocol_versions(self):
return self._table.protocol... | class RawDeltaTable():
def __init__(self, raw_delta_table):
self._table = raw_delta_table
self.schema = self._table.schema
self.version = self._table.version
def table_uri(self):
return self._table.table_uri()
def protocol_versions(self):
return self._table.protocol... | self._table.create_write_transaction(*args, **kwargs)
| self._table.create_write_transaction(*args, **kwargs)
| 2 | 123 | 18 | 141 | class RawDeltaTable():
def __init__(self, raw_delta_table):
self._table = raw_delta_table
self.schema = self._table.schema
self.version = self._table.version
def table_uri(self):
return self._table.table_uri()
def protocol_versions(self):
return self._table.protocol... | class RawDeltaTable():
def __init__(self, raw_delta_table):
self._table = raw_delta_table
self.schema = self._table.schema
self.version = self._table.version
def table_uri(self):
return self._table.table_uri()
def protocol_versions(self):
return self._table.protocol... |
20,722 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/delta_lake_s3/utils.py | 33,34 | 1,52 | __get_logs | 34,52 | 34,52 | import json
def fix_overwritten_partitions(client, bucket: str, key: str, version: int) -> None:
current = __get_logs(client, bucket, key, version)
partition_values = [row['add']['partitionValues'] for row in current['add']]
removes_updated = [row for row in current['remove'] if row['remove']['partitionV... | import json
def fix_overwritten_partitions(client, bucket: str, key: str, version: int) -> None:
current = __get_logs(client, bucket, key, version)
partition_values = [row['add']['partitionValues'] for row in current['add']]
removes_updated = [row for row in current['remove'] if row['remove']['partitionV... | data = client.get_object(Bucket=bucket, Key=__version_log_key(key, version))
content = data['Body'].read().decode()
lines = content.split('\n')
rows = [json.loads(line) for line in lines if line]
add_rows = []
remove_rows = []
other_rows = []
for row in rows:
if 'add' in row:
... | data = client.get_object(Bucket=bucket, Key=__version_log_key(key, version))
content = data['Body'].read().decode()
lines = content.split('\n')
rows = [json.loads(line) for line in lines if line]
add_rows = []
remove_rows = []
other_rows = []
for row in rows:
if 'add' in row:
... | 49 | 333 | 195 | 528 | import json
def fix_overwritten_partitions(client, bucket: str, key: str, version: int) -> None:
current = __get_logs(client, bucket, key, version)
partition_values = [row['add']['partitionValues'] for row in current['add']]
removes_updated = [row for row in current['remove'] if row['remove']['partitionV... | import json
def fix_overwritten_partitions(client, bucket: str, key: str, version: int) -> None:
current = __get_logs(client, bucket, key, version)
partition_values = [row['add']['partitionValues'] for row in current['add']]
removes_updated = [row for row in current['remove'] if row['remove']['partitionV... | |
20,723 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/mssql/utils.py | 87,88 | 1,102 | convert_column_type | 88,102 | 88,102 | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.consta... | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.consta... | if COLUMN_TYPE_BOOLEAN == column_type:
return 'CHAR(52)'
elif COLUMN_TYPE_INTEGER == column_type:
return 'BIGINT'
elif COLUMN_TYPE_NUMBER == column_type:
return 'DECIMAL'
elif COLUMN_TYPE_OBJECT == column_type:
return 'TEXT'
elif COLUMN_TYPE_STRING == column_type:
... | if COLUMN_TYPE_BOOLEAN == column_type:
return 'CHAR(52)'
elif COLUMN_TYPE_INTEGER == column_type:
return 'BIGINT'
elif COLUMN_TYPE_NUMBER == column_type:
return 'DECIMAL'
elif COLUMN_TYPE_OBJECT == column_type:
return 'TEXT'
elif COLUMN_TYPE_STRING == column_type:
... | 49 | 1,039 | 187 | 1,226 | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.consta... | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.consta... | |
20,724 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/mysql/utils.py | 104,105 | 1,119 | convert_column_type | 105,119 | 105,119 | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.sql.utils import (
convert_column_to_type as convert_column_to_type_orig,
)
from mage_integrations.... | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.sql.utils import (
convert_column_to_type as convert_column_to_type_orig,
)
from mage_integrations.... | if COLUMN_TYPE_BOOLEAN == column_type:
return 'CHAR(52)'
elif COLUMN_TYPE_INTEGER == column_type:
return 'UNSIGNED'
elif COLUMN_TYPE_NUMBER == column_type:
return 'DOUBLE'
elif COLUMN_TYPE_OBJECT == column_type:
return 'JSON'
elif COLUMN_TYPE_STRING == column_type:
... | if COLUMN_TYPE_BOOLEAN == column_type:
return 'CHAR(52)'
elif COLUMN_TYPE_INTEGER == column_type:
return 'UNSIGNED'
elif COLUMN_TYPE_NUMBER == column_type:
return 'DOUBLE'
elif COLUMN_TYPE_OBJECT == column_type:
return 'JSON'
elif COLUMN_TYPE_STRING == column_type:
... | 49 | 1,222 | 187 | 1,409 | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.sql.utils import (
convert_column_to_type as convert_column_to_type_orig,
)
from mage_integrations.... | from typing import Dict, List
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.sql.utils import (
convert_column_to_type as convert_column_to_type_orig,
)
from mage_integrations.... | |
20,725 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/oracledb/utils.py | 32,39 | 1,115 | build_alter_table_command | 39,51 | 39,51 | from typing import Dict, List
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLU... | from typing import Dict, List
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLU... | if not columns:
return None
columns_and_types = [
f"{column_identifier}{clean_column_name(col, use_lowercase)}{column_identifier}" +
f" {column_type_mapping[col]['type_converted']}" for col
in columns
]
# TODO: support add new unique constraints
return f"ALTER TABLE ... | if not columns:
return None
columns_and_types = [
f"{column_identifier}{clean_column_name(col, use_lowercase)}{column_identifier}" +
f" {column_type_mapping[col]['type_converted']}" for col
in columns
]
# TODO: support add new unique constraints
return f"ALTER TABLE ... | 32 | 1,230 | 129 | 1,359 | from typing import Dict, List
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLU... | from typing import Dict, List
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
from mage_integrations.destinations.utils import (
clean_column_name as clean_column_name_orig,
)
from mage_integrations.sources.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_BOOLEAN,
COLU... | |
20,726 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/postgresql/utils.py | 23,24 | 1,55 | convert_array | 24,43 | 24,43 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def escape_quotes(line: str, sin... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def escape_quotes(line: str, sin... | item_type_converted = column_type_dict['item_type_converted']
if 'JSONB' == item_type_converted.upper():
arr = []
for v2 in v:
if v2:
if type(v2) is dict:
v2 = json.dumps(v2)
arr.append(v2)
arr_joined = ', '.join([f"'{escape_qu... | item_type_converted = column_type_dict['item_type_converted']
if 'JSONB' == item_type_converted.upper():
arr = []
for v2 in v:
if v2:
if type(v2) is dict:
v2 = json.dumps(v2)
arr.append(v2)
arr_joined = ', '.join([f"'{escape_qu... | 53 | 348 | 229 | 577 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def escape_quotes(line: str, sin... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def escape_quotes(line: str, sin... | |
20,727 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/redshift/utils.py | 18,23 | 1,29 | convert_column_type | 23,29 | 23,29 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def convert_array(v: List, colum... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def convert_array(v: List, colum... | if COLUMN_TYPE_OBJECT == column_type:
return 'VARCHAR(65535)'
elif COLUMN_TYPE_STRING == column_type:
if COLUMN_FORMAT_DATETIME == column_settings.get('format'):
return 'TIMESTAMPTZ'
return convert_column_type_orig(column_type, column_settings, **kwargs)
| if COLUMN_TYPE_OBJECT == column_type:
return 'VARCHAR(65535)'
elif COLUMN_TYPE_STRING == column_type:
if COLUMN_FORMAT_DATETIME == column_settings.get('format'):
return 'TIMESTAMPTZ'
return convert_column_type_orig(column_type, column_settings, **kwargs)
| 20 | 176 | 105 | 281 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def convert_array(v: List, colum... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
convert_column_type as convert_column_type_orig,
)
def convert_array(v: List, colum... | |
20,728 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/salesforce/target_salesforce/utils/transformation.py | 10,11 | 1,26 | transform_record | 11,26 | 11,26 | """Converts python datetimes back to strings so the record is JSON Serializable"""
from typing import Dict
DATE_FORMAT = "%Y-%m-%d"
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
def transform_record(record: Dict, object_fields: Dict):
FILL_FUNC_BODY | """Converts python datetimes back to strings so the record is JSON Serializable"""
from typing import Dict
DATE_FORMAT = "%Y-%m-%d"
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
def transform_record(record: Dict, object_fields: Dict):
FILL_FUNC_BODY | transformed_record = {}
for field, value in record.items():
if value is None:
transformed_record[field] = value
continue
object_type = object_fields.get(field)
if object_type == "date":
transformed_record[field] = value.strftime(DATE_FORMAT)
e... | transformed_record = {}
for field, value in record.items():
if value is None:
transformed_record[field] = value
continue
object_type = object_fields.get(field)
if object_type == "date":
transformed_record[field] = value.strftime(DATE_FORMAT)
e... | 39 | 103 | 150 | 253 | """Converts python datetimes back to strings so the record is JSON Serializable"""
from typing import Dict
DATE_FORMAT = "%Y-%m-%d"
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
def transform_record(record: Dict, object_fields: Dict):
FILL_FUNC_BODY | """Converts python datetimes back to strings so the record is JSON Serializable"""
from typing import Dict
DATE_FORMAT = "%Y-%m-%d"
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
def transform_record(record: Dict, object_fields: Dict):
FILL_FUNC_BODY | |
20,729 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/salesforce/target_salesforce/utils/validation.py | 18,21 | 1,55 | validate_schema_field | 22,55 | 21,55 | """Currently Validates the following:
1. Field exists in the SF Object (excluding _sdc metadata)
2. If the config action is update, that the field can be updated
3. If the config action is insert, that the field can be created
4. If the config action is upsert, that the field can be created and updated"... | """Currently Validates the following:
1. Field exists in the SF Object (excluding _sdc metadata)
2. If the config action is update, that the field can be updated
3. If the config action is insert, that the field can be created
4. If the config action is upsert, that the field can be created and updated"... | field_name, field_type = field
sf_field: ObjectField = object_fields.get(field_name)
if field_name.startswith("_sdc_"):
return
if field_name == "Id":
if action == "insert":
raise InvalidStreamSchema(
f"Id is not createable and should not be included on inser... | """Currently only validates that all incomming fields exist in the SF Object"""
field_name, field_type = field
sf_field: ObjectField = object_fields.get(field_name)
if field_name.startswith("_sdc_"):
return
if field_name == "Id":
if action == "insert":
raise InvalidStre... | 110 | 223 | 344 | 567 | """Currently Validates the following:
1. Field exists in the SF Object (excluding _sdc metadata)
2. If the config action is update, that the field can be updated
3. If the config action is insert, that the field can be created
4. If the config action is upsert, that the field can be created and updated"... | """Currently Validates the following:
1. Field exists in the SF Object (excluding _sdc metadata)
2. If the config action is update, that the field can be updated
3. If the config action is insert, that the field can be created
4. If the config action is upsert, that the field can be created and updated"... | |
20,730 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/snowflake/utils.py | 23,30 | 1,93 | build_alter_table_command | 30,42 | 30,42 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_ARRAY,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.snowflake.constants import (
SNOWFLAKE_COLUMN_TYPE_VARIANT,
)
from mage_integrati... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_ARRAY,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.snowflake.constants import (
SNOWFLAKE_COLUMN_TYPE_VARIANT,
)
from mage_integrati... | if not columns:
return None
columns_and_types = [
f"{column_identifier}{clean_column_name(col, use_lowercase)}{column_identifier}" +
f" {column_type_mapping[col]['type_converted']}" for col
in columns
]
# TODO: support add new unique constraints
return f"ALTER TABLE ... | if not columns:
return None
columns_and_types = [
f"{column_identifier}{clean_column_name(col, use_lowercase)}{column_identifier}" +
f" {column_type_mapping[col]['type_converted']}" for col
in columns
]
# TODO: support add new unique constraints
return f"ALTER TABLE ... | 32 | 854 | 128 | 982 | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_ARRAY,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.snowflake.constants import (
SNOWFLAKE_COLUMN_TYPE_VARIANT,
)
from mage_integrati... | import json
from typing import Dict, List
from mage_integrations.destinations.constants import (
COLUMN_FORMAT_DATETIME,
COLUMN_TYPE_ARRAY,
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.snowflake.constants import (
SNOWFLAKE_COLUMN_TYPE_VARIANT,
)
from mage_integrati... | |
20,735 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/trino/connectors/deltalake.py | 17,22 | 1,54 | convert_column_type | 22,28 | 22,28 | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... | if COLUMN_TYPE_OBJECT == column_type:
return 'VARCHAR'
return convert_column_type_orig(column_type, column_settings, **kwargs)
| if COLUMN_TYPE_OBJECT == column_type:
return 'VARCHAR'
return convert_column_type_orig(column_type, column_settings, **kwargs)
| 10 | 522 | 54 | 576 | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... | |
20,736 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/trino/connectors/deltalake.py | 39,40 | 28,54 | convert_array | TrinoDeltalake | 40,54 | 40,54 | class TrinoDeltalake(TrinoConnector):
name = 'delta-lake'
def column_type_mapping(self, schema: Dict) -> Dict:
return column_type_mapping_orig(
schema,
convert_column_type,
lambda item_type_converted: f'ARRAY<{item_type_converted}>',
array_default_item_ty... | class TrinoDeltalake(TrinoConnector):
name = 'delta-lake'
def column_type_mapping(self, schema: Dict) -> Dict:
return column_type_mapping_orig(
schema,
convert_column_type,
lambda item_type_converted: f'ARRAY<{item_type_converted}>',
array_default_item_ty... | if len(value) == 0:
return 'NULL'
item_type_converted = column_type_dict['item_type_converted']
if item_type_converted == 'VARCHAR':
if len(value) > 0 and (type(value[0]) is dict or type(value[0]) is list):
value_serialized = json.dumps([json.dumps(i) for... | if len(value) == 0:
return 'NULL'
item_type_converted = column_type_dict['item_type_converted']
if item_type_converted == 'VARCHAR':
if len(value) > 0 and (type(value[0]) is dict or type(value[0]) is list):
value_serialized = json.dumps([json.dumps(i) for... | 49 | 153 | 206 | 359 | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... | import json
from typing import Dict
from mage_integrations.destinations.constants import (
COLUMN_TYPE_OBJECT,
COLUMN_TYPE_STRING,
)
from mage_integrations.destinations.sql.utils import (
column_type_mapping as column_type_mapping_orig,
)
from mage_integrations.destinations.sql.utils import (
convert_c... |
20,737 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/destinations/trino/utils.py | 17,18 | 1,19 | convert_json_or_string | 18,19 | 18,19 | from mage_integrations.destinations.constants import COLUMN_TYPE_OBJECT
from mage_integrations.destinations.sql.utils import convert_column_type as convert_column_type_orig
from typing import Dict
def convert_column_type(
column_type: str,
column_settings: Dict,
**kwargs,
) -> str:
if COLUMN_TYPE_OBJE... | from mage_integrations.destinations.constants import COLUMN_TYPE_OBJECT
from mage_integrations.destinations.sql.utils import convert_column_type as convert_column_type_orig
from typing import Dict
def convert_column_type(
column_type: str,
column_settings: Dict,
**kwargs,
) -> str:
if COLUMN_TYPE_OBJE... | return value.replace("'", '\"')
| return value.replace("'", '\"')
| 3 | 169 | 13 | 182 | from mage_integrations.destinations.constants import COLUMN_TYPE_OBJECT
from mage_integrations.destinations.sql.utils import convert_column_type as convert_column_type_orig
from typing import Dict
def convert_column_type(
column_type: str,
column_settings: Dict,
**kwargs,
) -> str:
if COLUMN_TYPE_OBJE... | from mage_integrations.destinations.constants import COLUMN_TYPE_OBJECT
from mage_integrations.destinations.sql.utils import convert_column_type as convert_column_type_orig
from typing import Dict
def convert_column_type(
column_type: str,
column_settings: Dict,
**kwargs,
) -> str:
if COLUMN_TYPE_OBJE... | |
20,738 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/addons.py | 18,19 | 4,20 | get_url | AddonsStream | 19,20 | 19,20 | class AddonsStream(BaseChargebeeStream):
TABLE = 'addons'
ENTITY = 'addon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'av... | class AddonsStream(BaseChargebeeStream):
TABLE = 'addons'
ENTITY = 'addon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'av... | return 'https://{}.chargebee.com/api/v2/addons'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/addons'.format(self.config.get('site'))
| 2 | 172 | 32 | 204 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class AddonsStream(BaseChargebeeStream):
TABLE = 'addons'
ENTITY = 'addon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTE... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class AddonsStream(BaseChargebeeStream):
TABLE = 'addons'
ENTITY = 'addon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTE... |
20,739 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/comments.py | 18,19 | 4,20 | get_url | CommentsStream | 19,20 | 19,20 | class CommentsStream(BaseChargebeeStream):
TABLE = 'comments'
ENTITY = 'comment'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'created_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['created_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['created_at']
INCLUSION... | class CommentsStream(BaseChargebeeStream):
TABLE = 'comments'
ENTITY = 'comment'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'created_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['created_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['created_at']
INCLUSION... | return 'https://{}.chargebee.com/api/v2/comments'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/comments'.format(self.config.get('site'))
| 2 | 170 | 31 | 201 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CommentsStream(BaseChargebeeStream):
TABLE = 'comments'
ENTITY = 'comment'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'created_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['created_at']
S... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CommentsStream(BaseChargebeeStream):
TABLE = 'comments'
ENTITY = 'comment'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'created_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['created_at']
S... |
20,740 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/coupons.py | 23,24 | 4,25 | get_url | CouponsStream | 24,25 | 24,25 | class CouponsStream(BaseChargebeeStream):
TABLE = 'coupons'
ENTITY = 'coupon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = ... | class CouponsStream(BaseChargebeeStream):
TABLE = 'coupons'
ENTITY = 'coupon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = ... | return 'https://{}.chargebee.com/api/v2/coupons'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/coupons'.format(self.config.get('site'))
| 2 | 251 | 32 | 283 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CouponsStream(BaseChargebeeStream):
TABLE = 'coupons'
ENTITY = 'coupon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELE... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CouponsStream(BaseChargebeeStream):
TABLE = 'coupons'
ENTITY = 'coupon'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELE... |
20,741 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/credit_notes.py | 18,19 | 4,20 | get_url | CreditNotesStream | 19,20 | 19,20 | class CreditNotesStream(BaseChargebeeStream):
TABLE = 'credit_notes'
ENTITY = 'credit_note'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
... | class CreditNotesStream(BaseChargebeeStream):
TABLE = 'credit_notes'
ENTITY = 'credit_note'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
... | return 'https://{}.chargebee.com/api/v2/credit_notes'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/credit_notes'.format(self.config.get('site'))
| 2 | 178 | 34 | 212 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CreditNotesStream(BaseChargebeeStream):
TABLE = 'credit_notes'
ENTITY = 'credit_note'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CreditNotesStream(BaseChargebeeStream):
TABLE = 'credit_notes'
ENTITY = 'credit_note'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated... |
20,742 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/customers.py | 18,19 | 4,20 | get_url | CustomersStream | 19,20 | 19,20 | class CustomersStream(BaseChargebeeStream):
TABLE = 'customers'
ENTITY = 'customer'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUS... | class CustomersStream(BaseChargebeeStream):
TABLE = 'customers'
ENTITY = 'customer'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUS... | return 'https://{}.chargebee.com/api/v2/customers'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/customers'.format(self.config.get('site'))
| 2 | 173 | 32 | 205 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CustomersStream(BaseChargebeeStream):
TABLE = 'customers'
ENTITY = 'customer'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class CustomersStream(BaseChargebeeStream):
TABLE = 'customers'
ENTITY = 'customer'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
... |
20,743 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/events.py | 23,24 | 4,25 | get_url | EventsStream | 24,25 | 24,25 | class EventsStream(BaseChargebeeStream):
TABLE = 'events'
ENTITY = 'event'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'occurred_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['occurred_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['occurred_at']
INCLUSION = ... | class EventsStream(BaseChargebeeStream):
TABLE = 'events'
ENTITY = 'event'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'occurred_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['occurred_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['occurred_at']
INCLUSION = ... | return 'https://{}.chargebee.com/api/v2/events'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/events'.format(self.config.get('site'))
| 2 | 254 | 31 | 285 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class EventsStream(BaseChargebeeStream):
TABLE = 'events'
ENTITY = 'event'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'occurred_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['occurred_at']
SELEC... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class EventsStream(BaseChargebeeStream):
TABLE = 'events'
ENTITY = 'event'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'occurred_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['occurred_at']
SELEC... |
20,744 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/gifts.py | 18,19 | 4,20 | get_url | GiftsStream | 19,20 | 19,20 | class GiftsStream(BaseChargebeeStream):
TABLE = 'gifts'
ENTITY = 'gift'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | class GiftsStream(BaseChargebeeStream):
TABLE = 'gifts'
ENTITY = 'gift'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | return 'https://{}.chargebee.com/api/v2/gifts'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/gifts'.format(self.config.get('site'))
| 2 | 170 | 32 | 202 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class GiftsStream(BaseChargebeeStream):
TABLE = 'gifts'
ENTITY = 'gift'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class GiftsStream(BaseChargebeeStream):
TABLE = 'gifts'
ENTITY = 'gift'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... |
20,745 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/invoices.py | 18,19 | 4,20 | get_url | InvoicesStream | 19,20 | 19,20 | class InvoicesStream(BaseChargebeeStream):
TABLE = 'invoices'
ENTITY = 'invoice'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION... | class InvoicesStream(BaseChargebeeStream):
TABLE = 'invoices'
ENTITY = 'invoice'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION... | return 'https://{}.chargebee.com/api/v2/invoices'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/invoices'.format(self.config.get('site'))
| 2 | 177 | 33 | 210 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class InvoicesStream(BaseChargebeeStream):
TABLE = 'invoices'
ENTITY = 'invoice'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
S... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class InvoicesStream(BaseChargebeeStream):
TABLE = 'invoices'
ENTITY = 'invoice'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
S... |
20,746 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/item_families.py | 18,19 | 4,20 | get_url | ItemFamiliesStream | 19,20 | 19,20 | class ItemFamiliesStream(BaseChargebeeStream):
TABLE = 'item_families'
ENTITY = 'item_family'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
... | class ItemFamiliesStream(BaseChargebeeStream):
TABLE = 'item_families'
ENTITY = 'item_family'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
... | return 'https://{}.chargebee.com/api/v2/item_families'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/item_families'.format(self.config.get('site'))
| 2 | 181 | 35 | 216 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemFamiliesStream(BaseChargebeeStream):
TABLE = 'item_families'
ENTITY = 'item_family'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updat... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemFamiliesStream(BaseChargebeeStream):
TABLE = 'item_families'
ENTITY = 'item_family'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updat... |
20,747 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/item_prices.py | 18,19 | 4,20 | get_url | ItemPricesStream | 19,20 | 19,20 | class ItemPricesStream(BaseChargebeeStream):
TABLE = 'item_prices'
ENTITY = 'item_price'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
I... | class ItemPricesStream(BaseChargebeeStream):
TABLE = 'item_prices'
ENTITY = 'item_price'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
I... | return 'https://{}.chargebee.com/api/v2/item_prices'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/item_prices'.format(self.config.get('site'))
| 2 | 182 | 34 | 216 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemPricesStream(BaseChargebeeStream):
TABLE = 'item_prices'
ENTITY = 'item_price'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemPricesStream(BaseChargebeeStream):
TABLE = 'item_prices'
ENTITY = 'item_price'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at... |
20,748 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/items.py | 18,19 | 4,20 | get_url | ItemsStream | 19,20 | 19,20 | class ItemsStream(BaseChargebeeStream):
TABLE = 'items'
ENTITY = 'item'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | class ItemsStream(BaseChargebeeStream):
TABLE = 'items'
ENTITY = 'item'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | return 'https://{}.chargebee.com/api/v2/items'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/items'.format(self.config.get('site'))
| 2 | 173 | 31 | 204 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemsStream(BaseChargebeeStream):
TABLE = 'items'
ENTITY = 'item'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class ItemsStream(BaseChargebeeStream):
TABLE = 'items'
ENTITY = 'item'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... |
20,749 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/orders.py | 18,19 | 4,20 | get_url | OrdersStream | 19,20 | 19,20 | class OrdersStream(BaseChargebeeStream):
TABLE = 'orders'
ENTITY = 'order'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'av... | class OrdersStream(BaseChargebeeStream):
TABLE = 'orders'
ENTITY = 'order'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'av... | return 'https://{}.chargebee.com/api/v2/orders'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/orders'.format(self.config.get('site'))
| 2 | 171 | 31 | 202 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class OrdersStream(BaseChargebeeStream):
TABLE = 'orders'
ENTITY = 'order'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTE... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class OrdersStream(BaseChargebeeStream):
TABLE = 'orders'
ENTITY = 'order'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTE... |
20,750 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/payment_sources.py | 18,19 | 4,20 | get_url | PaymentSourcesStream | 19,20 | 19,20 | class PaymentSourcesStream(BaseChargebeeStream):
TABLE = 'payment_sources'
ENTITY = 'payment_source'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['update... | class PaymentSourcesStream(BaseChargebeeStream):
TABLE = 'payment_sources'
ENTITY = 'payment_source'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['update... | return 'https://{}.chargebee.com/api/v2/payment_sources'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/payment_sources'.format(self.config.get('site'))
| 2 | 178 | 34 | 212 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class PaymentSourcesStream(BaseChargebeeStream):
TABLE = 'payment_sources'
ENTITY = 'payment_source'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class PaymentSourcesStream(BaseChargebeeStream):
TABLE = 'payment_sources'
ENTITY = 'payment_source'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ... |
20,751 | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai | /home/hieuvd/dung_repo/raw/stars_01/mage-ai_mage-ai/mage-ai/mage_integrations/mage_integrations/sources/chargebee/streams/plans.py | 18,19 | 4,20 | get_url | PlansStream | 19,20 | 19,20 | class PlansStream(BaseChargebeeStream):
TABLE = 'plans'
ENTITY = 'plan'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | class PlansStream(BaseChargebeeStream):
TABLE = 'plans'
ENTITY = 'plan'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_BY_DEFAULT = True
VALID_REPLICATION_KEYS = ['updated_at']
INCLUSION = 'avail... | return 'https://{}.chargebee.com/api/v2/plans'.format(self.config.get('site'))
| return 'https://{}.chargebee.com/api/v2/plans'.format(self.config.get('site'))
| 2 | 171 | 32 | 203 | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class PlansStream(BaseChargebeeStream):
TABLE = 'plans'
ENTITY = 'plan'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... | from mage_integrations.sources.chargebee.streams.base import BaseChargebeeStream
class PlansStream(BaseChargebeeStream):
TABLE = 'plans'
ENTITY = 'plan'
REPLICATION_METHOD = 'INCREMENTAL'
REPLICATION_KEY = 'updated_at'
KEY_PROPERTIES = ['id']
BOOKMARK_PROPERTIES = ['updated_at']
SELECTED_B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.