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,424 | /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/api/presenters/SparkStageAttemptTaskPresenter.py | 24,25 | 4,26 | prepare_present | SparkStageAttemptTaskPresenter | 25,26 | 25,26 | class SparkStageAttemptTaskPresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'attempt',
'duration',
'executor_id',
'executor_logs',
'getting_result_time',
'host',
'index',
'launch_time',
'partition_id',
'sc... | class SparkStageAttemptTaskPresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'attempt',
'duration',
'executor_id',
'executor_logs',
'getting_result_time',
'host',
'index',
'launch_time',
'partition_id',
'sc... | return self.model.to_dict()
| return self.model.to_dict()
| 2 | 163 | 12 | 175 | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkStageAttemptTaskPresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'attempt',
'duration',
'executor_id',
'executor_logs',
'getting_result_time',
'host',
'i... | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkStageAttemptTaskPresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'attempt',
'duration',
'executor_id',
'executor_logs',
'getting_result_time',
'host',
'i... |
20,425 | /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/api/presenters/SparkStageAttemptTaskSummaryPresenter.py | 26,27 | 4,28 | prepare_present | SparkStageAttemptTaskSummaryPresenter | 27,28 | 27,28 | class SparkStageAttemptTaskSummaryPresenter(BasePresenter):
default_attributes = [
'disk_bytes_spilled',
'duration',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize_time',
'executor_run_time',
'getting_result_time',
'input_m... | class SparkStageAttemptTaskSummaryPresenter(BasePresenter):
default_attributes = [
'disk_bytes_spilled',
'duration',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize_time',
'executor_run_time',
'getting_result_time',
'input_m... | return self.model.to_dict()
| return self.model.to_dict()
| 2 | 221 | 12 | 233 | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkStageAttemptTaskSummaryPresenter(BasePresenter):
default_attributes = [
'disk_bytes_spilled',
'duration',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize_time',
'ex... | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkStageAttemptTaskSummaryPresenter(BasePresenter):
default_attributes = [
'disk_bytes_spilled',
'duration',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize_time',
'ex... |
20,426 | /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/api/presenters/SparkStagePresenter.py | 68,69 | 6,72 | prepare_present | SparkStagePresenter | 69,72 | 69,72 | class SparkStagePresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'application',
'attempt_id',
'completion_time',
'details',
'disk_bytes_spilled',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize... | class SparkStagePresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
'application',
'attempt_id',
'completion_time',
'details',
'disk_bytes_spilled',
'executor_cpu_time',
'executor_deserialize_cpu_time',
'executor_deserialize... | return self.model.to_dict()
| return self.model.to_dict()
| 2 | 677 | 16 | 693 | from mage_ai.api.operations.constants import OperationType
from mage_ai.api.presenters.BasePresenter import BasePresenter
from mage_ai.api.presenters.SparkStageAttemptPresenter import SparkStageAttemptPresenter
class SparkStagePresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
... | from mage_ai.api.operations.constants import OperationType
from mage_ai.api.presenters.BasePresenter import BasePresenter
from mage_ai.api.presenters.SparkStageAttemptPresenter import SparkStageAttemptPresenter
class SparkStagePresenter(BasePresenter):
default_attributes = [
'accumulator_updates',
... |
20,427 | /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/api/presenters/SparkThreadPresenter.py | 14,15 | 4,16 | prepare_present | SparkThreadPresenter | 15,16 | 15,16 | class SparkThreadPresenter(BasePresenter):
default_attributes = [
'blocked_by_lock',
'holding_locks',
'stack_trace',
'thread_id',
'thread_name',
'thread_state',
]
async def prepare_present(self, **kwargs):
FILL_FUNC_BODY | class SparkThreadPresenter(BasePresenter):
default_attributes = [
'blocked_by_lock',
'holding_locks',
'stack_trace',
'thread_id',
'thread_name',
'thread_state',
]
async def prepare_present(self, **kwargs):
FILL_FUNC_BODY | return self.model.to_dict()
| return self.model.to_dict()
| 2 | 92 | 12 | 104 | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkThreadPresenter(BasePresenter):
default_attributes = [
'blocked_by_lock',
'holding_locks',
'stack_trace',
'thread_id',
'thread_name',
'thread_state',
]
async def prepare_present(self,... | from mage_ai.api.presenters.BasePresenter import BasePresenter
class SparkThreadPresenter(BasePresenter):
default_attributes = [
'blocked_by_lock',
'holding_locks',
'stack_trace',
'thread_id',
'thread_name',
'thread_state',
]
async def prepare_present(self,... |
20,428 | /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/api/presenters/SyncPresenter.py | 27,28 | 6,46 | present | SyncPresenter | 28,46 | 28,46 | class SyncPresenter(BasePresenter):
default_attributes = [
'access_token',
'access_token_secret_name',
'auth_type',
'branch',
'email',
'remote_repo_link',
'repo_path',
'ssh_private_key',
'ssh_private_key_secret_name',
'ssh_public_key',
... | class SyncPresenter(BasePresenter):
default_attributes = [
'access_token',
'access_token_secret_name',
'auth_type',
'branch',
'email',
'remote_repo_link',
'repo_path',
'ssh_private_key',
'ssh_private_key_secret_name',
'ssh_public_key',
... | data = self.model
def filter_invalid_secret_values(data):
for attribute in self.default_attributes:
if attribute.endswith('_secret_name'):
secret_name = data.get(attribute)
if secret_name and not get_secret_value(
... | data = self.model
def filter_invalid_secret_values(data):
for attribute in self.default_attributes:
if attribute.endswith('_secret_name'):
secret_name = data.get(attribute)
if secret_name and not get_secret_value(
... | 34 | 185 | 190 | 375 | from mage_ai.api.presenters.BasePresenter import BasePresenter
from mage_ai.data_preparation.shared.secrets import get_secret_value
from mage_ai.settings.repo import get_repo_path
class SyncPresenter(BasePresenter):
default_attributes = [
'access_token',
'access_token_secret_name',
'auth_t... | from mage_ai.api.presenters.BasePresenter import BasePresenter
from mage_ai.data_preparation.shared.secrets import get_secret_value
from mage_ai.settings.repo import get_repo_path
class SyncPresenter(BasePresenter):
default_attributes = [
'access_token',
'access_token_secret_name',
'auth_t... |
20,429 | /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/api/presenters/VersionControlBranchPresenter.py | 16,17 | 6,18 | prepare_present | VersionControlBranchPresenter | 17,18 | 17,18 | class VersionControlBranchPresenter(BasePresenter):
default_attributes = [
'current',
'name',
'output',
'project_uuid',
'remote',
'repo_path',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | class VersionControlBranchPresenter(BasePresenter):
default_attributes = [
'current',
'name',
'output',
'project_uuid',
'remote',
'repo_path',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | return self.resource.model.to_dict()
| return self.resource.model.to_dict()
| 2 | 86 | 14 | 100 | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlBranchPresenter(BasePresenter):
default_attributes = [
'current',
'name',
'output',
'project_uuid',
'remote',
'repo_path',
]
async def prepare_presen... | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlBranchPresenter(BasePresenter):
default_attributes = [
'current',
'name',
'output',
'project_uuid',
'remote',
'repo_path',
]
async def prepare_presen... |
20,430 | /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/api/presenters/VersionControlFilePresenter.py | 22,23 | 6,24 | prepare_present | VersionControlFilePresenter | 23,24 | 23,24 | class VersionControlFilePresenter(BasePresenter):
default_attributes = [
'additions',
'content',
'deletions',
'diff',
'file_path',
'name',
'output',
'project_uuid',
'repo_path',
'staged',
'unstaged',
'untracked',
]
... | class VersionControlFilePresenter(BasePresenter):
default_attributes = [
'additions',
'content',
'deletions',
'diff',
'file_path',
'name',
'output',
'project_uuid',
'repo_path',
'staged',
'unstaged',
'untracked',
]
... | return self.resource.model.to_dict()
| return self.resource.model.to_dict()
| 2 | 125 | 14 | 139 | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlFilePresenter(BasePresenter):
default_attributes = [
'additions',
'content',
'deletions',
'diff',
'file_path',
'name',
'output',
'project_uuid... | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlFilePresenter(BasePresenter):
default_attributes = [
'additions',
'content',
'deletions',
'diff',
'file_path',
'name',
'output',
'project_uuid... |
20,431 | /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/api/presenters/VersionControlProjectPresenter.py | 15,16 | 6,17 | prepare_present | VersionControlProjectPresenter | 16,17 | 16,17 | class VersionControlProjectPresenter(BasePresenter):
default_attributes = [
'output',
'repo_path',
'sync_config',
'user',
'uuid',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | class VersionControlProjectPresenter(BasePresenter):
default_attributes = [
'output',
'repo_path',
'sync_config',
'user',
'uuid',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | return self.resource.model.to_dict()
| return self.resource.model.to_dict()
| 2 | 80 | 14 | 94 | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlProjectPresenter(BasePresenter):
default_attributes = [
'output',
'repo_path',
'sync_config',
'user',
'uuid',
]
async def prepare_present(self, **kwargs) -> ... | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlProjectPresenter(BasePresenter):
default_attributes = [
'output',
'repo_path',
'sync_config',
'user',
'uuid',
]
async def prepare_present(self, **kwargs) -> ... |
20,432 | /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/api/presenters/VersionControlRemotePresenter.py | 15,16 | 6,17 | prepare_present | VersionControlRemotePresenter | 16,17 | 16,17 | class VersionControlRemotePresenter(BasePresenter):
default_attributes = [
'name',
'output',
'project_uuid',
'repo_path',
'url',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | class VersionControlRemotePresenter(BasePresenter):
default_attributes = [
'name',
'output',
'project_uuid',
'repo_path',
'url',
]
async def prepare_present(self, **kwargs) -> Dict:
FILL_FUNC_BODY | return self.resource.model.to_dict()
| return self.resource.model.to_dict()
| 2 | 80 | 14 | 94 | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlRemotePresenter(BasePresenter):
default_attributes = [
'name',
'output',
'project_uuid',
'repo_path',
'url',
]
async def prepare_present(self, **kwargs) -> D... | from typing import Dict
from mage_ai.api.presenters.BasePresenter import BasePresenter
class VersionControlRemotePresenter(BasePresenter):
default_attributes = [
'name',
'output',
'project_uuid',
'repo_path',
'url',
]
async def prepare_present(self, **kwargs) -> D... |
20,433 | /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/api/presenters/WidgetPresenter.py | 24,25 | 4,29 | present | WidgetPresenter | 25,29 | 25,29 | class WidgetPresenter(BasePresenter):
default_attributes = [
'all_upstream_blocks_executed',
'color',
'configuration',
'content',
'downstream_blocks',
'executor_config',
'executor_type',
'has_callback',
'language',
'name',
'outp... | class WidgetPresenter(BasePresenter):
default_attributes = [
'all_upstream_blocks_executed',
'color',
'configuration',
'content',
'downstream_blocks',
'executor_config',
'executor_type',
'has_callback',
'language',
'name',
'outp... | if type(self.model) is dict:
return self.model
return self.model.to_dict(include_content=True)
| if type(self.model) is dict:
return self.model
return self.model.to_dict(include_content=True)
| 8 | 145 | 40 | 185 | from mage_ai.api.presenters.BasePresenter import BasePresenter
class WidgetPresenter(BasePresenter):
default_attributes = [
'all_upstream_blocks_executed',
'color',
'configuration',
'content',
'downstream_blocks',
'executor_config',
'executor_type',
... | from mage_ai.api.presenters.BasePresenter import BasePresenter
class WidgetPresenter(BasePresenter):
default_attributes = [
'all_upstream_blocks_executed',
'color',
'configuration',
'content',
'downstream_blocks',
'executor_config',
'executor_type',
... |
20,436 | /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/api/resources/AsyncBaseResource.py | 6,7 | 5,40 | collective_load_for_attribute | AsyncBaseResource | 7,26 | 7,26 | class AsyncBaseResource(BaseResource):
async def collective_load_for_attribute(self, key):
FILL_FUNC_BODY async def __getattr__(self, name):
async def _missing(*args, **kwargs):
loader = self.__class__.collective_loader().get(name, None)
if loader:
arr = await self... | class AsyncBaseResource(BaseResource):
async def collective_load_for_attribute(self, key):
FILL_FUNC_BODY async def __getattr__(self, name):
async def _missing(*args, **kwargs):
loader = self.__class__.collective_loader().get(name, None)
if loader:
arr = await self... | k_name = self.__class__.__name__
if self.result_set().context and self.result_set().context.data:
loaded = self.result_set().context.data.get(k_name, {}).get(key, None)
else:
loaded = None
loader = self.__class__.collective_loader().get(key, None)
if not l... | k_name = self.__class__.__name__
if self.result_set().context and self.result_set().context.data:
loaded = self.result_set().context.data.get(k_name, {}).get(key, None)
else:
loaded = None
loader = self.__class__.collective_loader().get(key, None)
if not l... | 55 | 165 | 233 | 398 | from mage_ai.api.resources.BaseResource import BaseResource
from mage_ai.api.result_set import ResultSet
class AsyncBaseResource(BaseResource):
async def collective_load_for_attribute(self, key):
FILL_FUNC_BODY async def __getattr__(self, name):
async def _missing(*args, **kwargs):
loader =... | from mage_ai.api.resources.BaseResource import BaseResource
from mage_ai.api.result_set import ResultSet
class AsyncBaseResource(BaseResource):
async def collective_load_for_attribute(self, key):
FILL_FUNC_BODY async def __getattr__(self, name):
async def _missing(*args, **kwargs):
loader =... |
20,437 | /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/api/resources/BlockLayoutItemResource.py | 29,31 | 28,170 | member | BlockLayoutItemResource | 31,170 | 31,170 | class BlockLayoutItemResource(GenericResource):
@classmethod
async def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | class BlockLayoutItemResource(GenericResource):
@classmethod
async def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | variables = {}
query = kwargs.get('query') or {}
for k, v in query.items():
if re.match(r'[\w-]+\[\]$', k):
variables[k] = v
elif isinstance(v, list) and len(v) >= 1:
variables[k] = v[0]
else:
variables[k] = v
... | variables = {}
query = kwargs.get('query') or {}
for k, v in query.items():
if re.match(r'[\w-]+\[\]$', k):
variables[k] = v
elif isinstance(v, list) and len(v) >= 1:
variables[k] = v[0]
else:
variables[k] = v
... | 309 | 41 | 1,661 | 1,702 | import json
import os
import re
import traceback
import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block.block_factory import BlockFactory
from mage_ai.data_preparation.models.constants import BlockType
fro... | import json
import os
import re
import traceback
import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block.block_factory import BlockFactory
from mage_ai.data_preparation.models.constants import BlockType
fro... |
20,438 | /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/api/resources/BlockOutputResource.py | 14,17 | 9,41 | member | BlockOutputResource | 17,41 | 17,41 | class BlockOutputResource(GenericResource):
"""
Resource to fetch block output for the notebook. Created to support legacy
endpoint /api/pipelines/<pipeline_uuid>/blocks/<block_uuid>/outputs
"""
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | class BlockOutputResource(GenericResource):
"""
Resource to fetch block output for the notebook. Created to support legacy
endpoint /api/pipelines/<pipeline_uuid>/blocks/<block_uuid>/outputs
"""
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | block_uuid = pk
query = kwargs.get('query', {})
pipeline_uuid = query.get('pipeline_uuid', [None])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
outputs = []
if pipeline_uuid is not None:
repo_path = get_repo_path(user=user)
pipel... | block_uuid = pk
query = kwargs.get('query', {})
pipeline_uuid = query.get('pipeline_uuid', [None])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
outputs = []
if pipeline_uuid is not None:
repo_path = get_repo_path(user=user)
pipel... | 70 | 96 | 288 | 384 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import g... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import g... |
20,439 | /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/api/resources/BlockTemplateResource.py | 15,18 | 14,44 | collection | BlockTemplateResource | 18,36 | 18,36 | class BlockTemplateResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
model = TEMPLATES_BY_UUID.get(pk)
if not model:
raise ApiError(... | class BlockTemplateResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
model = TEMPLATES_BY_UUID.get(pk)
if not model:
raise ApiError(... | show_all = query.get('show_all', [None])
if show_all:
show_all = show_all[0]
arr = TEMPLATES.copy()
if show_all:
arr += TEMPLATES_ONLY_FOR_V2.copy()
if Project().is_feature_enabled(FeatureUUID.DATA_INTEGRATION_IN_BATCH_PIPELINE):
arr... | show_all = query.get('show_all', [None])
if show_all:
show_all = show_all[0]
arr = TEMPLATES.copy()
if show_all:
arr += TEMPLATES_ONLY_FOR_V2.copy()
if Project().is_feature_enabled(FeatureUUID.DATA_INTEGRATION_IN_BATCH_PIPELINE):
arr... | 28 | 132 | 164 | 296 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.data_preparation.models.project.constants import FeatureUUID
from mage_ai.data_preparation.templates.constants import (
TEMPLATES,
TE... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.data_preparation.models.project.constants import FeatureUUID
from mage_ai.data_preparation.templates.constants import (
TEMPLATES,
TE... |
20,440 | /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/api/resources/CacheItemResource.py | 16,18 | 15,112 | collection | CacheItemResource | 18,34 | 18,34 | class CacheItemResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
async def member(self, pk: str, user, **kwargs):
query = kwargs.get('query') or {}
item_type = query.get('item_type', [None])
if item_typ... | class CacheItemResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
async def member(self, pk: str, user, **kwargs):
query = kwargs.get('query') or {}
item_type = query.get('item_type', [None])
if item_typ... | item_type = query.get('item_type', [None])
if item_type:
item_type = item_type[0]
results = []
if CacheItemType.DBT == item_type:
cache = await DBTCache.initialize_cache_async(replace=False, root_project=True)
results.extend(cache.get_cache_items())
... | item_type = query.get('item_type', [None])
if item_type:
item_type = item_type[0]
results = []
if CacheItemType.DBT == item_type:
cache = await DBTCache.initialize_cache_async(replace=False, root_project=True)
results.extend(cache.get_cache_items())
... | 31 | 709 | 153 | 862 | import json
import logging
from io import StringIO
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.cache.constants import CacheItemType
from mage_ai.cache.dbt.cache import DBTCache
from mage_ai.cache.dbt.models import DBTCacheItem
from mage_ai.data_preparation.models.block.dbt.block ... | import json
import logging
from io import StringIO
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.cache.constants import CacheItemType
from mage_ai.cache.dbt.cache import DBTCache
from mage_ai.cache.dbt.models import DBTCacheItem
from mage_ai.data_preparation.models.block.dbt.block ... |
20,441 | /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/api/resources/ClientPageResource.py | 21,24 | 10,31 | member | ClientPageResource | 24,31 | 24,31 | class ClientPageResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
resources = await load_resources(ignore_keys(query or {}, ['api_key']))
result_set = self.build_result_set(CLIENT_PAGES.values(), user, **kwargs)
result_se... | class ClientPageResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
resources = await load_resources(ignore_keys(query or {}, ['api_key']))
result_set = self.build_result_set(CLIENT_PAGES.values(), user, **kwargs)
result_se... | query = kwargs.get('query') or {}
model = self(CLIENT_PAGES[urllib.parse.unquote(pk)], user, **kwargs)
resources = await load_resources(ignore_keys(query or {}, ['api_key']))
model.result_set().context.data['resources'] = resources
return model
| query = kwargs.get('query') or {}
model = self(CLIENT_PAGES[urllib.parse.unquote(pk)], user, **kwargs)
resources = await load_resources(ignore_keys(query or {}, ['api_key']))
model.result_set().context.data['resources'] = resources
return model
| 22 | 151 | 95 | 246 | import urllib.parse
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.presenters.pages.constants import CLIENT_PAGES
from mage_ai.presenters.pages.loaders.utils import load_resources
from mage_ai.shared.hash import ignore_keys
class Clie... | import urllib.parse
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.presenters.pages.constants import CLIENT_PAGES
from mage_ai.presenters.pages.loaders.utils import load_resources
from mage_ai.shared.hash import ignore_keys
class Clie... |
20,442 | /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/api/resources/ClusterResource.py | 11,14 | 10,55 | member | ClusterResource | 14,27 | 14,27 | class ClusterResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY @safe_db_query
def update(self, payload, **kwargs):
if ClusterType.EMR == self.model['type']:
from mage_ai.cluster_manager.aws.emr_cluster_manager import (
... | class ClusterResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY @safe_db_query
def update(self, payload, **kwargs):
if ClusterType.EMR == self.model['type']:
from mage_ai.cluster_manager.aws.emr_cluster_manager import (
... | clusters = []
if ClusterType.EMR == pk and get_active_kernel_name() == KernelName.PYSPARK:
from mage_ai.cluster_manager.aws.emr_cluster_manager import (
emr_cluster_manager,
)
clusters = emr_cluster_manager.list_clusters()
return self(dict(
... | clusters = []
if ClusterType.EMR == pk and get_active_kernel_name() == KernelName.PYSPARK:
from mage_ai.cluster_manager.aws.emr_cluster_manager import (
emr_cluster_manager,
)
clusters = emr_cluster_manager.list_clusters()
return self(dict(
... | 27 | 310 | 131 | 441 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.constants import ClusterType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.active_kernel import get_active_kernel_name
from mage_ai.server.kernels import Kernel... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.constants import ClusterType
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.active_kernel import get_active_kernel_name
from mage_ai.server.kernels import Kernel... |
20,443 | /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/api/resources/CommandCenterItemResource.py | 11,13 | 10,32 | create | CommandCenterItemResource | 13,32 | 13,32 | class CommandCenterItemResource(AsyncBaseResource):
@classmethod
async def create(self, payload: Dict, user: User, **kwargs) -> 'CommandCenterItemResource':
FILL_FUNC_BODY | class CommandCenterItemResource(AsyncBaseResource):
@classmethod
async def create(self, payload: Dict, user: User, **kwargs) -> 'CommandCenterItemResource':
FILL_FUNC_BODY | items = []
settings = None
if payload.get('settings'):
keys = dig(payload.get('settings'), ['interface', 'keyboard_shortcuts', 'main'])
keys = [k.strip() for k in (keys or '').split(',')]
settings = CommandCenterSettings.load(interface=dict(
k... | items = []
settings = None
if payload.get('settings'):
keys = dig(payload.get('settings'), ['interface', 'keyboard_shortcuts', 'main'])
keys = [k.strip() for k in (keys or '').split(',')]
settings = CommandCenterSettings.load(interface=dict(
k... | 56 | 54 | 217 | 271 | from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.command_center.models import CommandCenterSettings
from mage_ai.command_center.service import search_items
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.hash import dig
class Comman... | from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.command_center.models import CommandCenterSettings
from mage_ai.command_center.service import search_items
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.hash import dig
class Comman... |
20,444 | /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/api/resources/ComputeClusterResource.py | 10,12 | 9,110 | collection | ComputeClusterResource | 12,38 | 12,38 | class ComputeClusterResource(GenericResource):
@classmethod
async def collection(self, query_arg, _meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
async def member(self, pk, user, **kwargs):
parent_model = kwargs.get('parent_model')
cluster = None
if isinstance(parent_model, ... | class ComputeClusterResource(GenericResource):
@classmethod
async def collection(self, query_arg, _meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
async def member(self, pk, user, **kwargs):
parent_model = kwargs.get('parent_model')
cluster = None
if isinstance(parent_model, ... | parent_model = kwargs.get('parent_model')
include_all_states = query_arg.get('include_all_states', [None])
if include_all_states:
include_all_states = include_all_states[0]
clusters = []
if isinstance(parent_model, ComputeService):
if ComputeServiceUUID... | parent_model = kwargs.get('parent_model')
include_all_states = query_arg.get('include_all_states', [None])
if include_all_states:
include_all_states = include_all_states[0]
clusters = []
if isinstance(parent_model, ComputeService):
if ComputeServiceUUID... | 52 | 672 | 255 | 927 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.services.compute.aws.models import Cluster
from mage_ai.services.compute.models import ComputeService
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.ssh.aws.emr.models import close_tunnel
from mage_ai.s... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.services.compute.aws.models import Cluster
from mage_ai.services.compute.models import ComputeService
from mage_ai.services.spark.constants import ComputeServiceUUID
from mage_ai.services.ssh.aws.emr.models import close_tunnel
from mage_ai.s... |
20,445 | /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/api/resources/ComputeConnectionResource.py | 42,43 | 14,104 | update | ComputeConnectionResource | 43,104 | 43,104 | class ComputeConnectionResource(GenericResource):
@classmethod
async def collection(self, query_arg, _meta, user, **kwargs):
parent_model = kwargs.get('parent_model')
arr = []
if parent_model and isinstance(parent_model, ComputeService):
if ComputeServiceUUID.AWS_EMR == par... | class ComputeConnectionResource(GenericResource):
@classmethod
async def collection(self, query_arg, _meta, user, **kwargs):
parent_model = kwargs.get('parent_model')
arr = []
if parent_model and isinstance(parent_model, ComputeService):
if ComputeServiceUUID.AWS_EMR == par... | parent_model = kwargs.get('parent_model')
action_uuid = payload.get('action')
if not action_uuid:
return
if parent_model and isinstance(parent_model, ComputeService):
if ComputeServiceUUID.AWS_EMR == parent_model.uuid:
from mage_ai.services.comp... | parent_model = kwargs.get('parent_model')
action_uuid = payload.get('action')
if not action_uuid:
return
if parent_model and isinstance(parent_model, ComputeService):
if ComputeServiceUUID.AWS_EMR == parent_model.uuid:
from mage_ai.services.comp... | 112 | 297 | 619 | 916 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.services.compute.constants import (
ComputeConnectionActionUUID,
ComputeConnectionState,
)
from mage_ai.services.compute.models import ComputeConnection, ComputeService
from mage_ai.services.sp... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.services.compute.constants import (
ComputeConnectionActionUUID,
ComputeConnectionState,
)
from mage_ai.services.compute.models import ComputeConnection, ComputeService
from mage_ai.services.sp... |
20,446 | /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/api/resources/ComputeServiceResource.py | 23,25 | 6,36 | member | ComputeServiceResource | 25,36 | 25,36 | class ComputeServiceResource(GenericResource):
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
resource = await self.member(None, user, **kwargs)
return self.build_result_set(
[
resource.model,
],
user,
**kw... | class ComputeServiceResource(GenericResource):
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
resource = await self.member(None, user, **kwargs)
return self.build_result_set(
[
resource.model,
],
user,
**kw... | query_arg = kwargs.get('query', {})
with_clusters = query_arg.get('with_clusters', [False])
if with_clusters:
with_clusters = with_clusters[0]
compute_service = self.get_model(pk)
if with_clusters:
compute_service.with_clusters = with_clusters
r... | query_arg = kwargs.get('query', {})
with_clusters = query_arg.get('with_clusters', [False])
if with_clusters:
with_clusters = with_clusters[0]
compute_service = self.get_model(pk)
if with_clusters:
compute_service.with_clusters = with_clusters
r... | 25 | 150 | 132 | 282 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.services.compute.models import ComputeService
class ComputeServiceResource(GenericResource):
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.services.compute.models import ComputeService
class ComputeServiceResource(GenericResource):
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
... |
20,447 | /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/api/resources/ConfigurationOptionResource.py | 6,8 | 5,39 | collection | ConfigurationOptionResource | 8,39 | 8,39 | class ConfigurationOptionResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY | class ConfigurationOptionResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY | pipeline = kwargs.get('parent_model')
configuration_type = query.get('configuration_type', [None])
if configuration_type:
configuration_type = configuration_type[0]
option_type = query.get('option_type', [None])
if option_type:
option_type = option_type[... | pipeline = kwargs.get('parent_model')
configuration_type = query.get('configuration_type', [None])
if configuration_type:
configuration_type = configuration_type[0]
option_type = query.get('option_type', [None])
if option_type:
option_type = option_type[... | 55 | 43 | 282 | 325 | from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.settings.models.configuration_option import ConfigurationOption
class ConfigurationOptionResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY | from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.settings.models.configuration_option import ConfigurationOption
class ConfigurationOptionResource(AsyncBaseResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY |
20,448 | /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/api/resources/CustomDesignResource.py | 19,21 | 9,27 | member | CustomDesignResource | 21,27 | 21,27 | class CustomDesignResource(AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user, **kwargs):
results = []
if Project.is_feature_enabled_in_root_or_active_project(FeatureUUID.CUSTOM_DESIGN):
results = CustomDesign.get_all()
return self.bu... | class CustomDesignResource(AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user, **kwargs):
results = []
if Project.is_feature_enabled_in_root_or_active_project(FeatureUUID.CUSTOM_DESIGN):
results = CustomDesign.get_all()
return self.bu... | model = CustomDesign()
if Project.is_feature_enabled_in_root_or_active_project(FeatureUUID.CUSTOM_DESIGN):
model = CustomDesign.combine_in_order_of_priority()
return self(model, user, **kwargs)
| model = CustomDesign()
if Project.is_feature_enabled_in_root_or_active_project(FeatureUUID.CUSTOM_DESIGN):
model = CustomDesign.combine_in_order_of_priority()
return self(model, user, **kwargs)
| 12 | 139 | 78 | 217 | from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.data_preparation.models.project.constants import FeatureUUID
from mage_ai.presenters.design.models import CustomDesign
class CustomDesignResource(Asyn... | from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.data_preparation.models.project import Project
from mage_ai.data_preparation.models.project.constants import FeatureUUID
from mage_ai.presenters.design.models import CustomDesign
class CustomDesignResource(Asyn... |
20,449 | /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/api/resources/EventRuleResource.py | 6,9 | 5,20 | member | EventRuleResource | 9,20 | 9,20 | class EventRuleResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | class EventRuleResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | rules = []
if 'aws' == pk:
from mage_ai.services.aws.events.events import get_all_event_rules
try:
rules = get_all_event_rules()
except Exception as err:
print(f'[WARNING] EventRuleResource.member: {err}')
return self(dict(ru... | rules = []
if 'aws' == pk:
from mage_ai.services.aws.events.events import get_all_event_rules
try:
rules = get_all_event_rules()
except Exception as err:
print(f'[WARNING] EventRuleResource.member: {err}')
return self(dict(ru... | 26 | 47 | 110 | 157 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
class EventRuleResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
class EventRuleResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY |
20,450 | /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/api/resources/ExecutionStateResource.py | 8,10 | 7,35 | collection | ExecutionStateResource | 10,35 | 10,35 | class ExecutionStateResource(GenericResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY | class ExecutionStateResource(GenericResource):
@classmethod
async def collection(self, query, _meta, user, **kwargs):
FILL_FUNC_BODY | arr = []
pipeline_uuid = query.get('pipeline_uuid', [False])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
block_uuid = query.get('block_uuid', [False])
if block_uuid:
block_uuid = block_uuid[0]
if pipeline_uuid and block_uuid:
... | arr = []
pipeline_uuid = query.get('pipeline_uuid', [False])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
block_uuid = query.get('block_uuid', [False])
if block_uuid:
block_uuid = block_uuid[0]
if pipeline_uuid and block_uuid:
... | 58 | 43 | 272 | 315 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.constants import PipelineType
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.settings.repo import get_repo_path
class ExecutionStateResource(GenericResource):
@classmethod
async d... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.constants import PipelineType
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.settings.repo import get_repo_path
class ExecutionStateResource(GenericResource):
@classmethod
async d... |
20,451 | /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/api/resources/ExtensionOptionResource.py | 17,20 | 7,25 | member | ExtensionOptionResource | 20,25 | 20,25 | class ExtensionOptionResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
return self.build_result_set(
EXTENSIONS,
user,
**kwargs,
)
@classmethod
@safe_db_query
def member(self, pk, user, *... | class ExtensionOptionResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
return self.build_result_set(
EXTENSIONS,
user,
**kwargs,
)
@classmethod
@safe_db_query
def member(self, pk, user, *... | model = EXTENSIONS_BY_UUID.get(pk)
if not model:
raise ApiError(ApiError.RESOURCE_NOT_FOUND)
return self(model, user, **kwargs)
| model = EXTENSIONS_BY_UUID.get(pk)
if not model:
raise ApiError(ApiError.RESOURCE_NOT_FOUND)
return self(model, user, **kwargs)
| 12 | 108 | 61 | 169 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.extensions.constants import EXTENSIONS, EXTENSIONS_BY_UUID
from mage_ai.orchestration.db import safe_db_query
class ExtensionOptionResource(GenericResource):
@classmethod
@safe_db_query
d... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.extensions.constants import EXTENSIONS, EXTENSIONS_BY_UUID
from mage_ai.orchestration.db import safe_db_query
class ExtensionOptionResource(GenericResource):
@classmethod
@safe_db_query
d... |
20,452 | /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/api/resources/FileContentResource.py | 17,20 | 16,70 | member | FileContentResource | 20,47 | 20,47 | class FileContentResource(GenericResource):
@classmethod
@safe_db_query
async def member(self, pk, user, **kwargs):
FILL_FUNC_BODY async def update(self, payload, **kwargs):
error = ApiError.RESOURCE_INVALID.copy()
content = payload.get('content')
version = payload.get('version')... | class FileContentResource(GenericResource):
@classmethod
@safe_db_query
async def member(self, pk, user, **kwargs):
FILL_FUNC_BODY async def update(self, payload, **kwargs):
error = ApiError.RESOURCE_INVALID.copy()
content = payload.get('content')
version = payload.get('version')... | file = None
if 'payload' in kwargs and 'file_content' in kwargs['payload']:
payload = kwargs['payload']['file_content']
if 'block_uuid' in payload and 'pipeline_uuid' in payload:
repo_path = get_repo_path(user=user)
pipeline = await Pipeline.get_a... | file = None
if 'payload' in kwargs and 'file_content' in kwargs['payload']:
payload = kwargs['payload']['file_content']
if 'block_uuid' in payload and 'pipeline_uuid' in payload:
repo_path = get_repo_path(user=user)
pipeline = await Pipeline.get_a... | 76 | 316 | 338 | 654 | import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object import BlockActionObjectCache
from mage_ai.data_preparation.models.block import Block
from mage_ai.data_preparation.models.errors import FileNotInProjectE... | import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object import BlockActionObjectCache
from mage_ai.data_preparation.models.block import Block
from mage_ai.data_preparation.models.errors import FileNotInProjectE... |
20,454 | /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/api/resources/FileVersionResource.py | 11,14 | 10,42 | collection | FileVersionResource | 14,42 | 14,42 | class FileVersionResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | class FileVersionResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | parent_model = kwargs.get('parent_model')
pipeline_uuid = query.get('pipeline_uuid', [False])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
block_uuid = query.get('block_uuid', [False])
if block_uuid:
block_uuid = block_uuid[0]
if pipeline_... | parent_model = kwargs.get('parent_model')
pipeline_uuid = query.get('pipeline_uuid', [False])
if pipeline_uuid:
pipeline_uuid = pipeline_uuid[0]
block_uuid = query.get('block_uuid', [False])
if block_uuid:
block_uuid = block_uuid[0]
if pipeline_... | 58 | 48 | 286 | 334 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block import Block
from mage_ai.data_preparation.models.file import File
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.orchestration.db import safe_... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block import Block
from mage_ai.data_preparation.models.file import File
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.orchestration.db import safe_... |
20,455 | /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/api/resources/FolderResource.py | 15,16 | 1,54 | full_path | 16,21 | 16,21 | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... | return os.path.join(get_repo_path(
root_project=True,
), *list(filter(lambda x: x and len(x) >= 1, args)))
| return os.path.join(get_repo_path(
root_project=True,
), *list(filter(lambda x: x and len(x) >= 1, args)))
| 12 | 595 | 52 | 647 | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... | |
20,456 | /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/api/resources/FolderResource.py | 22,25 | 21,54 | create | FolderResource | 25,30 | 25,30 | class FolderResource(GenericResource):
@classmethod
@safe_db_query
def create(cls, payload: Dict, user, **kwargs) -> 'FolderResource':
FILL_FUNC_BODY @classmethod
def member(cls, pk, user, **kwargs):
path = add_absolute_path(urllib.parse.unquote(pk))
return cls(dict(path=path), user, ... | class FolderResource(GenericResource):
@classmethod
@safe_db_query
def create(cls, payload: Dict, user, **kwargs) -> 'FolderResource':
FILL_FUNC_BODY @classmethod
def member(cls, pk, user, **kwargs):
path = add_absolute_path(urllib.parse.unquote(pk))
return cls(dict(path=path), user, ... | path = full_path(payload.get('path'), payload.get('name'))
cls.check_folder_is_in_project(path)
os.makedirs(path, exist_ok=True if payload.get('overwrite', False) else False)
return cls(dict(path=path), user, **kwargs)
| path = full_path(payload.get('path'), payload.get('name'))
cls.check_folder_is_in_project(path)
os.makedirs(path, exist_ok=True if payload.get('overwrite', False) else False)
return cls(dict(path=path), user, **kwargs)
| 16 | 342 | 89 | 431 | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... | import os
import shutil
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.errors import FileNotInProjectError
from mage_ai.data_preparation.models.file import ensure_file_is_in_proje... |
20,457 | /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/api/resources/GenericResource.py | 6,7 | 4,11 | _missing | GenericResource | 7,10 | 7,10 | class GenericResource(BaseResource):
def __getattr__(self, name):
def _missing(*args, **kwargs):
FILL_FUNC_BODY return _missing()
| class GenericResource(BaseResource):
def __getattr__(self, name):
def _missing(*args, **kwargs):
FILL_FUNC_BODY return _missing()
| if type(self.model) is dict:
return self.model.get(name)
return self.model
| if type(self.model) is dict:
return self.model.get(name)
return self.model
| 8 | 49 | 32 | 81 | from mage_ai.api.resources.BaseResource import BaseResource
class GenericResource(BaseResource):
def __getattr__(self, name):
def _missing(*args, **kwargs):
FILL_FUNC_BODY return _missing()
| from mage_ai.api.resources.BaseResource import BaseResource
class GenericResource(BaseResource):
def __getattr__(self, name):
def _missing(*args, **kwargs):
FILL_FUNC_BODY return _missing()
|
20,458 | /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/api/resources/GitCustomBranchResource.py | 57,58 | 8,63 | remotes | GitCustomBranchResource | 58,63 | 58,63 | class GitCustomBranchResource(GitBranchResource):
@classmethod
def get_git_manager(
self, user, setup_repo: bool = False, config_overwrite: Dict = None
) -> Git:
return Git.get_manager(
auth_type=AuthType.OAUTH,
config_overwrite=config_overwrite,
setup_rep... | class GitCustomBranchResource(GitBranchResource):
@classmethod
def get_git_manager(
self, user, setup_repo: bool = False, config_overwrite: Dict = None
) -> Git:
return Git.get_manager(
auth_type=AuthType.OAUTH,
config_overwrite=config_overwrite,
setup_rep... | git_manager = self.get_git_manager(user=self.current_user)
remotes = git_manager.remotes(limit=limit, user=self.current_user)
# Filter out the remote used by git sync/git integration since it will not work
# properly with the version control app.
return list(filter(lambda remote:... | git_manager = self.get_git_manager(user=self.current_user)
remotes = git_manager.remotes(limit=limit, user=self.current_user)
# Filter out the remote used by git sync/git integration since it will not work
# properly with the version control app.
return list(filter(lambda remote:... | 36 | 446 | 108 | 554 | from typing import Dict, List
from mage_ai.api.resources.GitBranchResource import GitBranchResource
from mage_ai.data_preparation.git import REMOTE_NAME, Git, api
from mage_ai.data_preparation.sync import AuthType
class GitCustomBranchResource(GitBranchResource):
@classmethod
def get_git_manager(
sel... | from typing import Dict, List
from mage_ai.api.resources.GitBranchResource import GitBranchResource
from mage_ai.data_preparation.git import REMOTE_NAME, Git, api
from mage_ai.data_preparation.sync import AuthType
class GitCustomBranchResource(GitBranchResource):
@classmethod
def get_git_manager(
sel... |
20,459 | /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/api/resources/GlobalDataProductResource.py | 18,20 | 8,56 | create | GlobalDataProductResource | 20,36 | 20,36 | class GlobalDataProductResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
repo_path = get_repo_path(user=user)
return self.build_result_set(
sorted(GlobalDataProduct.load_all(repo_path), key=lambda x: x.uuid),
user,
**kw... | class GlobalDataProductResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
repo_path = get_repo_path(user=user)
return self.build_result_set(
sorted(GlobalDataProduct.load_all(repo_path), key=lambda x: x.uuid),
user,
**kw... | repo_path = get_repo_path(user=user)
uuid = payload.get('uuid')
if GlobalDataProduct.get(uuid, repo_path):
error = ApiError.RESOURCE_INVALID.copy()
error.update(dict(message=f'A global data product with UUID {uuid} already exists.'))
raise ApiError(error)
... | repo_path = get_repo_path(user=user)
uuid = payload.get('uuid')
if GlobalDataProduct.get(uuid, repo_path):
error = ApiError.RESOURCE_INVALID.copy()
error.update(dict(message=f'A global data product with UUID {uuid} already exists.'))
raise ApiError(error)
... | 36 | 372 | 170 | 542 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.global_data_product import GlobalDataProduct
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.hash import ignore_keys
class GlobalDataProductResource(Generi... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.global_data_product import GlobalDataProduct
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.hash import ignore_keys
class GlobalDataProductResource(Generi... |
20,460 | /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/api/resources/IntegrationDestinationResource.py | 24,27 | 12,44 | create | IntegrationDestinationResource | 27,44 | 27,44 | class IntegrationDestinationResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
collection = get_collection('destinations', DESTINATIONS)
return self.build_result_set(
collection,
user,
**kwargs,... | class IntegrationDestinationResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
collection = get_collection('destinations', DESTINATIONS)
return self.build_result_set(
collection,
user,
**kwargs,... | error_message = None
success = False
action_type = payload['action_type']
if 'test_connection' == action_type:
pipeline_uuid = payload['pipeline_uuid']
repo_path = get_repo_path(user=user)
pipeline = IntegrationPipeline.get(pipeline_uuid, repo_path=re... | error_message = None
success = False
action_type = payload['action_type']
if 'test_connection' == action_type:
pipeline_uuid = payload['pipeline_uuid']
repo_path = get_repo_path(user=user)
pipeline = IntegrationPipeline.get(pipeline_uuid, repo_path=re... | 44 | 124 | 190 | 314 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_integrations.destinations.constants import DESTINATIONS
from mage_ai.data_preparation.models.constants import BlockType
from mage_ai.data_preparation.models.pipelines.integration_pipeline import (
IntegrationPipeline,
)
from mage_ai... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_integrations.destinations.constants import DESTINATIONS
from mage_ai.data_preparation.models.constants import BlockType
from mage_ai.data_preparation.models.pipelines.integration_pipeline import (
IntegrationPipeline,
)
from mage_ai... |
20,462 | /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/api/resources/IntegrationSourceResource.py | 137,140 | 98,230 | create | IntegrationSourceResource | 140,186 | 140,186 | class IntegrationSourceResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
collection = []
parent_model = kwargs.get('parent_model')
if parent_model and isinstance(parent_model, Pipeline):
block_uuids = query.ge... | class IntegrationSourceResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
collection = []
parent_model = kwargs.get('parent_model')
if parent_model and isinstance(parent_model, Pipeline):
block_uuids = query.ge... | error_message = None
success = False
streams = []
repo_path = get_repo_path(user=user)
action_type = payload['action_type']
if 'test_connection' == action_type:
pipeline_uuid = payload['pipeline_uuid']
block_uuid = payload.get('block_uuid')
... | error_message = None
success = False
streams = []
repo_path = get_repo_path(user=user)
action_type = payload['action_type']
if 'test_connection' == action_type:
pipeline_uuid = payload['pipeline_uuid']
block_uuid = payload.get('block_uuid')
... | 100 | 802 | 456 | 1,258 | import traceback
import urllib.parse
from typing import Dict, List
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.PipelineRunResource import PipelineRunResource
from mage_ai.api.resources.PipelineScheduleResource import PipelineScheduleResource
from mage_ai.data_integratio... | import traceback
import urllib.parse
from typing import Dict, List
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.PipelineRunResource import PipelineRunResource
from mage_ai.api.resources.PipelineScheduleResource import PipelineScheduleResource
from mage_ai.data_integratio... |
20,463 | /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/api/resources/IntegrationSourceStreamResource.py | 10,13 | 9,15 | member | IntegrationSourceStreamResource | 13,15 | 13,15 | class IntegrationSourceStreamResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | class IntegrationSourceStreamResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | repo_path = get_repo_path(user=user)
return self(IntegrationPipeline.get(pk, repo_path=repo_path), user, **kwargs)
| repo_path = get_repo_path(user=user)
return self(IntegrationPipeline.get(pk, repo_path=repo_path), user, **kwargs)
| 8 | 49 | 45 | 94 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.pipelines.integration_pipeline import (
IntegrationPipeline,
)
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import get_repo_path
class IntegrationSourceStreamResource(GenericReso... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.pipelines.integration_pipeline import (
IntegrationPipeline,
)
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import get_repo_path
class IntegrationSourceStreamResource(GenericReso... |
20,464 | /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/api/resources/InteractionResource.py | 96,97 | 15,108 | update | InteractionResource | 97,108 | 97,108 | class InteractionResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
pipeline_interaction = kwargs.get('parent_model')
interactions = []
async def load_interaction(uuid) -> Dict:
interaction = Interaction(uuid, ... | class InteractionResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
pipeline_interaction = kwargs.get('parent_model')
interactions = []
async def load_interaction(uuid) -> Dict:
interaction = Interaction(uuid, ... | payload_update = {}
if 'content' in payload:
payload_update['content'] = payload.get('content')
else:
payload_update['content_parsed'] = extract(payload, [
'inputs',
'layout',
'variables',
])
await self.... | payload_update = {}
if 'content' in payload:
payload_update['content'] = payload.get('content')
else:
payload_update['content_parsed'] = extract(payload, [
'inputs',
'layout',
'variables',
])
await self.... | 21 | 753 | 101 | 854 | import asyncio
import os
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.presenters.interactions.models import Interaction
from mage_ai.shared.environmen... | import asyncio
import os
import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.presenters.interactions.models import Interaction
from mage_ai.shared.environmen... |
20,465 | /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/api/resources/KernelResource.py | 14,17 | 13,78 | collection | KernelResource | 17,30 | 17,30 | class KernelResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
kernel_fallback = None
kernels_by_id = {}
for kernel_name in KernelName:
... | class KernelResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
kernel_fallback = None
kernels_by_id = {}
for kernel_name in KernelName:
... | kernels = []
for kernel_name in KernelName:
kernel = kernel_managers[kernel_name]
if kernel.has_kernel:
kernels.append(kernel)
return self.build_result_set(
kernels,
user,
**kwargs,
)
| kernels = []
for kernel_name in KernelName:
kernel = kernel_managers[kernel_name]
if kernel.has_kernel:
kernels.append(kernel)
return self.build_result_set(
kernels,
user,
**kwargs,
)
| 19 | 431 | 88 | 519 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.active_kernel import (
interrupt_kernel,
restart_kernel,
start_kernel,
switch_active_kernel,
)
from mage_ai.server.kernels import DEFAULT_KERNEL_NAME, KernelName, kern... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.active_kernel import (
interrupt_kernel,
restart_kernel,
start_kernel,
switch_active_kernel,
)
from mage_ai.server.kernels import DEFAULT_KERNEL_NAME, KernelName, kern... |
20,466 | /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/api/resources/LlmResource.py | 6,8 | 5,14 | create | LlmResource | 8,14 | 8,14 | class LlmResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | class LlmResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | response = await Generator.generate(payload.get('use_case'), payload.get('request'))
return self(dict(
use_case=payload.get('use_case'),
response=response,
), user, **kwargs)
| response = await Generator.generate(payload.get('use_case'), payload.get('request'))
return self(dict(
use_case=payload.get('use_case'),
response=response,
), user, **kwargs)
| 12 | 39 | 68 | 107 | from mage_ai.ai.generator import Generator
from mage_ai.api.resources.GenericResource import GenericResource
class LlmResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | from mage_ai.ai.generator import Generator
from mage_ai.api.resources.GenericResource import GenericResource
class LlmResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY |
20,467 | /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/api/resources/MonitorStatResource.py | 7,10 | 6,55 | member | MonitorStatResource | 10,55 | 10,55 | class MonitorStatResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | class MonitorStatResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_BODY | query = kwargs.get('query', {})
pipeline_uuids = query.get('pipeline_uuid', None)
if pipeline_uuids:
pipeline_uuid = pipeline_uuids[0]
else:
pipeline_uuid = None
start_times = query.get('start_time', None)
if start_times:
start_time =... | query = kwargs.get('query', {})
pipeline_uuids = query.get('pipeline_uuid', None)
if pipeline_uuids:
pipeline_uuid = pipeline_uuids[0]
else:
pipeline_uuid = None
start_times = query.get('start_time', None)
if start_times:
start_time =... | 86 | 47 | 465 | 512 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.monitor.monitor_stats import MonitorStats
class MonitorStatResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.monitor.monitor_stats import MonitorStats
class MonitorStatResource(GenericResource):
@classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
FILL_FUNC_... |
20,468 | /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/api/resources/OauthAccessTokenResource.py | 10,13 | 7,25 | collection | OauthAccessTokenResource | 13,25 | 13,25 | class OauthAccessTokenResource(DatabaseResource):
model_class = Oauth2AccessToken
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
FILL_FUNC_BODY | class OauthAccessTokenResource(DatabaseResource):
model_class = Oauth2AccessToken
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
FILL_FUNC_BODY | results = Oauth2AccessToken.query.filter(Oauth2AccessToken.user_id == user.id)
show_all = query_arg.get('show_all', [None])
if show_all:
show_all = show_all[0]
if not show_all:
results = results.filter(Oauth2AccessToken.expires > datetime.utcnow())
resu... | results = Oauth2AccessToken.query.filter(Oauth2AccessToken.user_id == user.id)
show_all = query_arg.get('show_all', [None])
if show_all:
show_all = show_all[0]
if not show_all:
results = results.filter(Oauth2AccessToken.expires > datetime.utcnow())
resu... | 27 | 64 | 138 | 202 | from datetime import datetime
from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.oauth import Oauth2AccessToken
class OauthAccessTokenResource(DatabaseResource):
model_class = Oauth2AccessToken
@classmeth... | from datetime import datetime
from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.oauth import Oauth2AccessToken
class OauthAccessTokenResource(DatabaseResource):
model_class = Oauth2AccessToken
@classmeth... |
20,470 | /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/api/resources/PageBlockLayoutResource.py | 27,28 | 12,92 | update | PageBlockLayoutResource | 28,92 | 28,92 | class PageBlockLayoutResource(GenericResource):
@classmethod
def get_model(self, pk, **kwargs):
uuid = urllib.parse.unquote(pk)
return PageBlockLayout.load(uuid)
@classmethod
def member(self, pk, user, **kwargs):
model = self.get_model(pk)
if not model:
rais... | class PageBlockLayoutResource(GenericResource):
@classmethod
def get_model(self, pk, **kwargs):
uuid = urllib.parse.unquote(pk)
return PageBlockLayout.load(uuid)
@classmethod
def member(self, pk, user, **kwargs):
model = self.get_model(pk)
if not model:
rais... | blocks = payload.get('blocks') or {}
layout = payload.get('layout') or []
blocks_with_content = {}
blocks_with_new_names = {}
for block_uuid, block_config in blocks.items():
block_name = block_config.get('name')
block_name_new = block_config.get('name_ne... | blocks = payload.get('blocks') or {}
layout = payload.get('layout') or []
blocks_with_content = {}
blocks_with_new_names = {}
for block_uuid, block_config in blocks.items():
block_name = block_config.get('name')
block_name_new = block_config.get('name_ne... | 147 | 153 | 736 | 889 | import os
import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block.block_factory import BlockFactory
from mage_ai.presenters.block_layout.page import PageBlockLayout
from mage_ai.shared.hash import extract, ... | import os
import urllib.parse
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.block.block_factory import BlockFactory
from mage_ai.presenters.block_layout.page import PageBlockLayout
from mage_ai.shared.hash import extract, ... |
20,471 | /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/api/resources/PermissionResource.py | 35,38 | 7,83 | create | PermissionResource | 38,45 | 38,45 | class PermissionResource(DatabaseResource):
model_class = Permission
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
only_entity_options = query_arg.get('only_entity_options', [False])
if only_entity_options:
only_entity_options = only_enti... | class PermissionResource(DatabaseResource):
model_class = Permission
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
only_entity_options = query_arg.get('only_entity_options', [False])
if only_entity_options:
only_entity_options = only_enti... | if 'entity_name' not in payload:
payload['entity_name'] = ''
return super().create(merge_dict(payload, dict(
user_id=user.id if user else None,
)), user, **kwargs)
| if 'entity_name' not in payload:
payload['entity_name'] = ''
return super().create(merge_dict(payload, dict(
user_id=user.id if user else None,
)), user, **kwargs)
| 19 | 618 | 70 | 688 | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import db_connection, safe_db_query
from mage_ai.orchestration.db.models.oauth import Permission, Role, RolePermission
from mage_ai.shared.hash import ignore_keys, index_by, merge_dict
class PermissionResource(DatabaseRe... | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import db_connection, safe_db_query
from mage_ai.orchestration.db.models.oauth import Permission, Role, RolePermission
from mage_ai.shared.hash import ignore_keys, index_by, merge_dict
class PermissionResource(DatabaseRe... |
20,472 | /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/api/resources/PipelineInteractionResource.py | 37,38 | 12,66 | update | PipelineInteractionResource | 38,66 | 38,66 | class PipelineInteractionResource(GenericResource):
@classmethod
@safe_db_query
async def get_model(self, pk, **kwargs):
uuid = urllib.parse.unquote(pk)
user = kwargs.get('user')
repo_path = get_repo_path(user=user)
pipeline = await Pipeline.get_async(uuid, repo_path=repo_pat... | class PipelineInteractionResource(GenericResource):
@classmethod
@safe_db_query
async def get_model(self, pk, **kwargs):
uuid = urllib.parse.unquote(pk)
user = kwargs.get('user')
repo_path = get_repo_path(user=user)
pipeline = await Pipeline.get_async(uuid, repo_path=repo_pat... | payload_update = {}
if 'content' in payload:
payload_update['content'] = payload.get('content')
else:
payload_update['content_parsed'] = extract(payload, [
'blocks',
'layout',
'permissions',
])
await sel... | payload_update = {}
if 'content' in payload:
payload_update['content'] = payload.get('content')
else:
payload_update['content_parsed'] = extract(payload, [
'blocks',
'layout',
'permissions',
])
await sel... | 50 | 292 | 240 | 532 | import urllib.parse
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.InteractionResource import InteractionResource
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.pipelines.interactions import PipelineInteractions
from mage... | import urllib.parse
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.InteractionResource import InteractionResource
from mage_ai.data_preparation.models.pipeline import Pipeline
from mage_ai.data_preparation.models.pipelines.interactions import PipelineInteractions
from mage... |
20,473 | /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/api/resources/PipelineTriggerResource.py | 24,27 | 12,61 | create | PipelineTriggerResource | 27,61 | 27,61 | class PipelineTriggerResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
parent_model = kwargs['parent_model']
return self.build_result_set(
get_triggers_by_pipeline(parent_model.uuid),
user,
**kwargs,... | class PipelineTriggerResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
parent_model = kwargs['parent_model']
return self.build_result_set(
get_triggers_by_pipeline(parent_model.uuid),
user,
**kwargs,... | parent_model = kwargs['parent_model']
error = ApiError.RESOURCE_INVALID
pipeline_schedule_id = payload.get('pipeline_schedule_id')
trigger_name = payload.get('name')
if not pipeline_schedule_id and not trigger_name:
error.update(dict(message='Pipeline schedule ID or ... | parent_model = kwargs['parent_model']
error = ApiError.RESOURCE_INVALID
pipeline_schedule_id = payload.get('pipeline_schedule_id')
trigger_name = payload.get('name')
if not pipeline_schedule_id and not trigger_name:
error.update(dict(message='Pipeline schedule ID or ... | 71 | 135 | 435 | 570 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.triggers import (
Trigger,
add_or_update_trigger_for_pipeline_and_persist,
get_triggers_by_pipeline,
)
from mage_ai.orchestration.db import safe_db_query
from mage_a... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.triggers import (
Trigger,
add_or_update_trigger_for_pipeline_and_persist,
get_triggers_by_pipeline,
)
from mage_ai.orchestration.db import safe_db_query
from mage_a... |
20,474 | /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/api/resources/PullRequestResource.py | 13,14 | 1,111 | pull_request_to_dict | 14,28 | 14,28 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... | return dict(
body=pr.body,
created_at=pr.created_at,
id=pr.id,
is_merged=pr.is_merged(),
last_modified=pr.last_modified,
merged=pr.merged,
state=pr.state,
title=pr.title,
url=pr.html_url,
user=pr.user.login,
)
| return dict(
body=pr.body,
created_at=pr.created_at,
id=pr.id,
is_merged=pr.is_merged(),
last_modified=pr.last_modified,
merged=pr.merged,
state=pr.state,
title=pr.title,
url=pr.html_url,
user=pr.user.login,
)
| 13 | 836 | 125 | 961 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... | |
20,475 | /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/api/resources/PullRequestResource.py | 29,31 | 28,111 | collection | PullRequestResource | 31,54 | 31,54 | class PullRequestResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
def create(self, payload, user, **kwargs):
error = ApiError.RESOURCE_INVALID
for key in [
'base_branch',
'compare_branch',
... | class PullRequestResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
def create(self, payload, user, **kwargs):
error = ApiError.RESOURCE_INVALID
for key in [
'base_branch',
'compare_branch',
... | arr = []
remote_url = query.get('remote_url', None)
if remote_url:
remote_url = remote_url[0]
repository = query.get('repository', None)
if repository:
repository = repository[0]
provider = ProviderName.GITHUB
if remote_url:
... | arr = []
remote_url = query.get('remote_url', None)
if remote_url:
remote_url = remote_url[0]
repository = query.get('repository', None)
if repository:
repository = repository[0]
provider = ProviderName.GITHUB
if remote_url:
... | 44 | 495 | 217 | 712 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.data_preparation.git.clients.base import Client as GitClient
from mage_ai.data_preparation.git.utils import (
... |
20,476 | /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/api/resources/RolePermissionResource.py | 10,13 | 7,32 | create | RolePermissionResource | 13,32 | 13,32 | class RolePermissionResource(DatabaseResource):
model_class = RolePermission
@classmethod
@safe_db_query
def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | class RolePermissionResource(DatabaseResource):
model_class = RolePermission
@classmethod
@safe_db_query
def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | payload_updated = merge_dict(payload, dict(
user_id=user.id if user else None,
))
resources = []
if 'permission_ids' in payload_updated:
permission_ids = payload_updated.get('permission_ids') or []
for permission_id in permission_ids:
... | payload_updated = merge_dict(payload, dict(
user_id=user.id if user else None,
))
resources = []
if 'permission_ids' in payload_updated:
permission_ids = payload_updated.get('permission_ids') or []
for permission_id in permission_ids:
... | 47 | 57 | 197 | 254 | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.oauth import Role, RolePermission
from mage_ai.shared.hash import ignore_keys, merge_dict
class RolePermissionResource(DatabaseResource):
model_class = RolePe... | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.oauth import Role, RolePermission
from mage_ai.shared.hash import ignore_keys, merge_dict
class RolePermissionResource(DatabaseResource):
model_class = RolePe... |
20,478 | /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/api/resources/RoleResource.py | 13,16 | 10,143 | collection | RoleResource | 16,65 | 16,65 | class RoleResource(DatabaseResource):
model_class = Role
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def create(self, payload, user, **kwargs):
return super().create(merge_dict(extract(payload, [
... | class RoleResource(DatabaseResource):
model_class = Role
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def create(self, payload, user, **kwargs):
return super().create(merge_dict(extract(payload, [
... | from mage_ai.orchestration.db.models.oauth import Permission
limit_roles = query.get('limit_roles', [None])
if limit_roles:
limit_roles = limit_roles[0]
entity = query.get('entity', [None])
if entity:
entity = entity[0]
entity_ids = query.get('e... | from mage_ai.orchestration.db.models.oauth import Permission
limit_roles = query.get('limit_roles', [None])
if limit_roles:
limit_roles = limit_roles[0]
entity = query.get('entity', [None])
if entity:
entity = entity[0]
entity_ids = query.get('e... | 126 | 832 | 506 | 1,338 | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.data_preparation.repo_manager import get_project_uuid
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db import db_connection, safe_db_query
from mage_ai.orchestration.db.models.oauth import Role, RolePermissi... | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.data_preparation.repo_manager import get_project_uuid
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db import db_connection, safe_db_query
from mage_ai.orchestration.db.models.oauth import Role, RolePermissi... |
20,479 | /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/api/resources/SchedulerResource.py | 16,19 | 6,27 | create | SchedulerResource | 19,27 | 19,27 | class SchedulerResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
scheduler = dict(status=scheduler_manager.get_status())
return self.build_result_set(
[scheduler],
user,
**kwargs,
)
@classmethod
@safe_d... | class SchedulerResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
scheduler = dict(status=scheduler_manager.get_status())
return self.build_result_set(
[scheduler],
user,
**kwargs,
)
@classmethod
@safe_d... | action_type = payload.get('action_type')
if action_type == 'start':
scheduler_manager.start_scheduler()
elif action_type == 'stop':
scheduler_manager.stop_scheduler()
return self(dict(status=scheduler_manager.get_status()), user, **kwargs)
| action_type = payload.get('action_type')
if action_type == 'start':
scheduler_manager.start_scheduler()
elif action_type == 'stop':
scheduler_manager.stop_scheduler()
return self(dict(status=scheduler_manager.get_status()), user, **kwargs)
| 17 | 116 | 91 | 207 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.scheduler_manager import scheduler_manager
class SchedulerResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
scheduler = dict... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.orchestration.db import safe_db_query
from mage_ai.server.scheduler_manager import scheduler_manager
class SchedulerResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
scheduler = dict... |
20,480 | /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/api/resources/SearchResultResource.py | 19,20 | 1,80 | filter_results | 20,53 | 20,53 | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... | block_action_object = result.get('block_action_object')
object_type = result.get('object_type')
block_type = None
language = None
if OBJECT_TYPE_BLOCK_FILE == object_type:
block_type = block_action_object.get('type')
language = block_action_object.get('language')
elif OBJECT_TY... | block_action_object = result.get('block_action_object')
object_type = result.get('object_type')
block_type = None
language = None
if OBJECT_TYPE_BLOCK_FILE == object_type:
block_type = block_action_object.get('type')
language = block_action_object.get('language')
elif OBJECT_TY... | 70 | 482 | 347 | 829 | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... | |
20,481 | /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/api/resources/SearchResultResource.py | 54,56 | 53,80 | create | SearchResultResource | 56,80 | 56,80 | class SearchResultResource(GenericResource):
@classmethod
async def create(self, payload: Dict, user, **kwargs):
FILL_FUNC_BODY | class SearchResultResource(GenericResource):
@classmethod
async def create(self, payload: Dict, user, **kwargs):
FILL_FUNC_BODY | pipeline_type = payload.get('pipeline_type', None) or None
query = payload.get('query', None) or None
ratio = payload.get('ratio', None) or None
search_type = payload.get('type', None) or None
results = []
if query:
if SEARCH_TYPE_BLOCK_ACTION_OBJECTS == sea... | pipeline_type = payload.get('pipeline_type', None) or None
query = payload.get('query', None) or None
ratio = payload.get('ratio', None) or None
search_type = payload.get('type', None) or None
results = []
if query:
if SEARCH_TYPE_BLOCK_ACTION_OBJECTS == sea... | 72 | 42 | 248 | 290 | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... | from typing import Dict
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cache.block_action_object.constants import (
OBJECT_TYPE_BLOCK_FILE,
OBJECT_TYPE_CUSTOM_BLOCK_TEMPLATE,
OBJECT_TYPE_MAGE_TEMPLATE,
)
from mage_ai.data_preparation.models.constants import (
BlockLangua... |
20,482 | /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/api/resources/SecretResource.py | 67,69 | 29,80 | _filter_secrets | SecretResource | 69,80 | 69,80 | class SecretResource(DatabaseResource):
model_class = Secret
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
entity = query.get('entity', [Entity.GLOBAL])
if entity:
entity = entity[0]
pipeline_uuid = query.get('pipeline_uuid', [None])... | class SecretResource(DatabaseResource):
model_class = Secret
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
entity = query.get('entity', [Entity.GLOBAL])
if entity:
entity = entity[0]
pipeline_uuid = query.get('pipeline_uuid', [None])... | # Only include git secrets that were created by the current user.
preferences = GitConfig(get_preferences(user=user).sync_config)
whitelist_secrets = [
preferences.ssh_private_key_secret_name,
preferences.ssh_public_key_secret_name,
preferences.access_token_se... | # Only include git secrets that were created by the current user.
preferences = GitConfig(get_preferences(user=user).sync_config)
whitelist_secrets = [
preferences.ssh_private_key_secret_name,
preferences.ssh_public_key_secret_name,
preferences.access_token_se... | 38 | 389 | 205 | 594 | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.data_preparation.preferences import get_preferences
from mage_ai.data_preparation.repo_manager import get_project_uuid
from mage_ai.data_preparation.shared.secrets import (
create_secret,
get... | from mage_ai.api.errors import ApiError
from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.data_preparation.preferences import get_preferences
from mage_ai.data_preparation.repo_manager import get_project_uuid
from mage_ai.data_preparation.shared.secrets import (
create_secret,
get... |
20,483 | /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/api/resources/SeedResource.py | 9,11 | 8,20 | create | SeedResource | 11,20 | 11,20 | class SeedResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | class SeedResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | if payload.get('roles') and payload.get('permissions'):
policy_names = payload.get('policy_names')
t = threading.Thread(
target=asyncio.run,
args=(bootstrap_permissions(policy_names=policy_names),),
)
t.start()
return self(... | if payload.get('roles') and payload.get('permissions'):
policy_names = payload.get('policy_names')
t = threading.Thread(
target=asyncio.run,
args=(bootstrap_permissions(policy_names=policy_names),),
)
t.start()
return self(... | 18 | 39 | 100 | 139 | import asyncio
import threading
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.permissions.seed import bootstrap_permissions
class SeedResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY | import asyncio
import threading
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.authentication.permissions.seed import bootstrap_permissions
class SeedResource(GenericResource):
@classmethod
async def create(self, payload, user, **kwargs):
FILL_FUNC_BODY |
20,484 | /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/api/resources/SessionResource.py | 22,25 | 21,154 | create | SessionResource | 25,141 | 25,141 | class SessionResource(BaseResource):
@classmethod
@safe_db_query
async def create(self, payload, _, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
return self(kwargs['oauth_token'], user, **kwargs)
@safe_db_query
def update(self, paylo... | class SessionResource(BaseResource):
@classmethod
@safe_db_query
async def create(self, payload, _, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def member(self, pk, user, **kwargs):
return self(kwargs['oauth_token'], user, **kwargs)
@safe_db_query
def update(self, paylo... | email = payload.get('email')
password = payload.get('password')
username = payload.get('username')
token = payload.get('token')
provider = payload.get('provider')
oauth_client = kwargs.get('oauth_client')
update_roles_on_login = get_bool_value(
get_s... | email = payload.get('email')
password = payload.get('password')
username = payload.get('username')
token = payload.get('token')
provider = payload.get('provider')
oauth_client = kwargs.get('oauth_client')
update_roles_on_login = get_bool_value(
get_s... | 332 | 170 | 1,407 | 1,577 | from datetime import datetime
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.BaseResource import BaseResource
from mage_ai.authentication.ldap import new_ldap_connection
from mage_ai.authentication.oauth2 import encode_token, generate_access_token
from mage_ai.authentication.passwords import verify... | from datetime import datetime
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.BaseResource import BaseResource
from mage_ai.authentication.ldap import new_ldap_connection
from mage_ai.authentication.oauth2 import encode_token, generate_access_token
from mage_ai.authentication.passwords import verify... |
20,485 | /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/api/resources/SparkApplicationResource.py | 12,14 | 7,30 | collection | SparkApplicationResource | 14,30 | 14,30 | class SparkApplicationResource(GenericResource, SparkApplicationChild):
@classmethod
async def get_model(self, pk, **kwargs):
return Application.load(id=pk)
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
FILL_FUNC_BODY | class SparkApplicationResource(GenericResource, SparkApplicationChild):
@classmethod
async def get_model(self, pk, **kwargs):
return Application.load(id=pk)
@classmethod
async def collection(self, _query, _meta, user, **kwargs):
FILL_FUNC_BODY | applications = await self.build_api().applications()
mapping = index_by(lambda x: x.id, applications)
applications_cache = Application.get_applications_from_cache()
if applications_cache:
for application in applications_cache.values():
if application.calculat... | applications = await self.build_api().applications()
mapping = index_by(lambda x: x.id, applications)
applications_cache = Application.get_applications_from_cache()
if applications_cache:
for application in applications_cache.values():
if application.calculat... | 34 | 82 | 147 | 229 | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.mixins.spark import SparkApplicationChild
from mage_ai.services.spark.models.applications import Application
from mage_ai.shared.hash import index_by
class SparkApplicationResource(GenericResource, SparkApplicationChild):
... | from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.api.resources.mixins.spark import SparkApplicationChild
from mage_ai.services.spark.models.applications import Application
from mage_ai.shared.hash import index_by
class SparkApplicationResource(GenericResource, SparkApplicationChild):
... |
20,486 | /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/api/resources/StatusResource.py | 25,28 | 24,100 | collection | StatusResource | 28,100 | 28,100 | class StatusResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | class StatusResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PROJECT_ID,
KUBE_NAMESPACE,
)
instance_type = None
project_type = get_project_type()
repo_config = get_repo_config()
if repo_config.cluster_type:
instanc... | from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PROJECT_ID,
KUBE_NAMESPACE,
)
instance_type = None
project_type = get_project_type()
repo_config = get_repo_config()
if repo_config.cluster_type:
instanc... | 160 | 47 | 1,007 | 1,054 | import os
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.constants import ClusterType
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
from mage_ai.data_preparation.repo_manager import (
get_project_type,
get_project_uuid,
get_repo... | import os
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.constants import ClusterType
from mage_ai.data_preparation.models.constants import MAX_PRINT_OUTPUT_LINES
from mage_ai.data_preparation.repo_manager import (
get_project_type,
get_project_uuid,
get_repo... |
20,488 | /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/api/resources/SyncResource.py | 104,105 | 39,172 | update | SyncResource | 105,127 | 105,127 | class SyncResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
sync_config = self.get_project_sync_config(user)
return self.build_result_set(
[sync_config],
user,
**kwargs,
)
@classmethod
@safe_db_query
... | class SyncResource(GenericResource):
@classmethod
def collection(self, query, meta, user, **kwargs):
sync_config = self.get_project_sync_config(user)
return self.build_result_set(
[sync_config],
user,
**kwargs,
)
@classmethod
@safe_db_query
... | self.model.pop('user_git_settings')
config = GitConfig.load(config=self.model)
sync = GitSync(config)
git_manager = sync.git_manager
action_type = payload.get('action_type')
try:
if action_type == 'sync_data':
sync.sync_data()
elif ... | self.model.pop('user_git_settings')
config = GitConfig.load(config=self.model)
sync = GitSync(config)
git_manager = sync.git_manager
action_type = payload.get('action_type')
try:
if action_type == 'sync_data':
sync.sync_data()
elif ... | 52 | 1,352 | 235 | 1,587 | import os
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.preferences import get_preferences
from mage_ai.data_preparation.shared.secrets import create_secret
from mage_ai.data_preparation.sync import (
... | import os
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.preferences import get_preferences
from mage_ai.data_preparation.shared.secrets import create_secret
from mage_ai.data_preparation.sync import (
... |
20,489 | /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/api/resources/TagResource.py | 11,14 | 8,29 | collection | TagResource | 14,29 | 14,29 | class TagResource(DatabaseResource):
model_class = Tag
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | class TagResource(DatabaseResource):
model_class = Tag
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY | cache = await TagCache.initialize_cache()
tag_uuids = cache.get_tags().keys()
tags = sorted(
unique_by(
list(Tag.query.all()) + [Tag(name=uuid) for uuid in tag_uuids],
lambda x: x.name,
),
key=lambda x: x.name,
)
... | cache = await TagCache.initialize_cache()
tag_uuids = cache.get_tags().keys()
tags = sorted(
unique_by(
list(Tag.query.all()) + [Tag(name=uuid) for uuid in tag_uuids],
lambda x: x.name,
),
key=lambda x: x.name,
)
... | 32 | 56 | 137 | 193 | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.cache.tag import TagCache
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.tags import Tag
from mage_ai.shared.array import unique_by
class TagResource(DatabaseResource):
model_class = Tag
... | from mage_ai.api.resources.DatabaseResource import DatabaseResource
from mage_ai.cache.tag import TagCache
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db.models.tags import Tag
from mage_ai.shared.array import unique_by
class TagResource(DatabaseResource):
model_class = Tag
... |
20,492 | /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/api/resources/VariableResource.py | 16,22 | 1,171 | get_variable_value | 22,40 | 22,40 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... | variable = variable_manager.get_variable_object(
pipeline_uuid,
block_uuid,
variable_uuid,
)
if variable.variable_type in [VariableType.DATAFRAME, VariableType.GEO_DATAFRAME]:
value = 'DataFrame'
variable_type = 'pandas.DataFrame'
else:
value = variable.re... | variable = variable_manager.get_variable_object(
pipeline_uuid,
block_uuid,
variable_uuid,
)
if variable.variable_type in [VariableType.DATAFRAME, VariableType.GEO_DATAFRAME]:
value = 'DataFrame'
variable_type = 'pandas.DataFrame'
else:
value = variable.re... | 31 | 1,335 | 166 | 1,501 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... | |
20,493 | /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/api/resources/VariableResource.py | 41,44 | 40,171 | collection | VariableResource | 44,94 | 44,94 | class VariableResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def create(self, payload: Dict, user, **kwargs) -> 'VariableResource':
pipeline_uuid = kwargs['parent_model'].uuid
er... | class VariableResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query, meta, user, **kwargs):
FILL_FUNC_BODY @classmethod
@safe_db_query
def create(self, payload: Dict, user, **kwargs) -> 'VariableResource':
pipeline_uuid = kwargs['parent_model'].uuid
er... | pipeline_uuid = kwargs['parent_model'].uuid
global_only = query.get('global_only', [False])
if global_only:
global_only = global_only[0]
# Get global variables from project's path
global_variables = [
dict(
uuid=uuid,
type... | pipeline_uuid = kwargs['parent_model'].uuid
global_only = query.get('global_only', [False])
if global_only:
global_only = global_only[0]
# Get global variables from project's path
global_variables = [
dict(
uuid=uuid,
type... | 102 | 731 | 458 | 1,189 | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... | from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.variable import VariableType
from mage_ai.data_preparation.variable_manager import (
VariableManager,
delete_global_variable,
get_global_var... |
20,494 | /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/api/resources/VersionControlBranchResource.py | 65,66 | 10,89 | delete | VersionControlBranchResource | 66,75 | 66,75 | class VersionControlBranchResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
remote = query.get('remote', [None])
if remote:
remote = remote[0]
... | class VersionControlBranchResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
remote = query.get('remote', [None])
if remote:
remote = remote[0]
... | query = kwargs.get('query') or {}
force = query.get('force', [None])
if force:
force = force[0]
self.model.delete(force=force)
self.validate_output()
| query = kwargs.get('query') or {}
force = query.get('force', [None])
if force:
force = force[0]
self.model.delete(force=force)
self.validate_output()
| 16 | 604 | 72 | 676 | import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import Branch, Remote
class... | import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import Branch, Remote
class... |
20,495 | /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/api/resources/VersionControlFileResource.py | 11,12 | 1,84 | get_detail | 12,16 | 12,16 | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... | await model.detail_async()
return model
| await model.detail_async()
return model
| 4 | 718 | 19 | 737 | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... | |
20,496 | /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/api/resources/VersionControlFileResource.py | 54,56 | 21,84 | create | VersionControlFileResource | 56,66 | 56,66 | class VersionControlFileResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
models = File.load_all(project=project)
diff = query.get('diff', [None])
if d... | class VersionControlFileResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
models = File.load_all(project=project)
diff = query.get('diff', [None])
if d... | project = kwargs.get('parent_model')
model = File()
model.project = project
model.name = payload.get('name')
model.create()
res = self(model, user, **kwargs)
res.validate_output()
return res
| project = kwargs.get('parent_model')
model = File()
model.project = project
model.name = payload.get('name')
model.create()
res = self(model, user, **kwargs)
res.validate_output()
return res
| 21 | 503 | 82 | 585 | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... | import asyncio
import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import File
... |
20,497 | /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/api/resources/VersionControlProjectResource.py | 39,41 | 12,86 | member | VersionControlProjectResource | 41,55 | 41,55 | class VersionControlProjectResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
return self.build_result_set(
Project.load_all(),
user,
**kwargs,
)
@classmethod
asy... | class VersionControlProjectResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
return self.build_result_set(
Project.load_all(),
user,
**kwargs,
)
@classmethod
asy... | model = self.get_model(pk)
sync_resource = SyncResource.member(None, user, repo_path=model.repo_path)
model.sync_config = await SyncResource.presenter_class()(
sync_resource,
user,
**kwargs,
).present()
res = self(model, user, **kwargs)
... | model = self.get_model(pk)
sync_resource = SyncResource.member(None, user, repo_path=model.repo_path)
model.sync_config = await SyncResource.presenter_class()(
sync_resource,
user,
**kwargs,
).present()
res = self(model, user, **kwargs)
... | 24 | 527 | 120 | 647 | import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.api.resources.SyncResource import SyncResource
from mage_ai.orchest... | import urllib.parse
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.api.resources.SyncResource import SyncResource
from mage_ai.orchest... |
20,498 | /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/api/resources/VersionControlRemoteResource.py | 54,55 | 10,66 | update | VersionControlRemoteResource | 55,63 | 55,63 | class VersionControlRemoteResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
models = Remote.load_all(project=project)
return self.build_result_set(
... | class VersionControlRemoteResource(VersionControlErrors, AsyncBaseResource):
@classmethod
async def collection(self, query: Dict, _meta: Dict, user: User, **kwargs):
project = kwargs.get('parent_model')
models = Remote.load_all(project=project)
return self.build_result_set(
... | if payload.get('fetch'):
self.model.update(fetch=True)
if payload.get('name') or payload.get('url'):
self.model.name = payload.get('name') or self.model.name
self.model.url = payload.get('url') or self.model.url
self.model.update(set_url=True)
self... | if payload.get('fetch'):
self.model.update(fetch=True)
if payload.get('name') or payload.get('url'):
self.model.name = payload.get('name') or self.model.name
self.model.url = payload.get('url') or self.model.url
self.model.update(set_url=True)
self... | 19 | 397 | 110 | 507 | import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import Remote
class Version... | import urllib.parse
from typing import Dict
from mage_ai.api.resources.AsyncBaseResource import AsyncBaseResource
from mage_ai.api.resources.mixins.version_control_errors import VersionControlErrors
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.version_control.models import Remote
class Version... |
20,499 | /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/api/resources/WidgetResource.py | 34,37 | 11,84 | create | WidgetResource | 37,59 | 37,59 | class WidgetResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
pipeline = kwargs['parent_model']
include_outputs = query.get('include_outputs', [True])
if include_outputs:
include_outputs = include_outputs[0]
... | class WidgetResource(GenericResource):
@classmethod
@safe_db_query
async def collection(self, query, meta, user, **kwargs):
pipeline = kwargs['parent_model']
include_outputs = query.get('include_outputs', [True])
if include_outputs:
include_outputs = include_outputs[0]
... | pipeline = kwargs['parent_model']
resource = Widget.create(
payload.get('name') or payload.get('uuid'),
payload.get('type'),
get_repo_path(user=user),
config=payload.get('config'),
language=payload.get('language'),
pipeline=pipelin... | pipeline = kwargs['parent_model']
resource = Widget.create(
payload.get('name') or payload.get('uuid'),
payload.get('type'),
get_repo_path(user=user),
config=payload.get('config'),
language=payload.get('language'),
pipeline=pipelin... | 33 | 464 | 217 | 681 | import asyncio
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.widget import Widget
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import get_repo_path
class WidgetRes... | import asyncio
from typing import Dict
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.data_preparation.models.widget import Widget
from mage_ai.orchestration.db import safe_db_query
from mage_ai.settings.repo import get_repo_path
class WidgetRes... |
20,500 | /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/api/resources/WorkspaceResource.py | 157,159 | 24,180 | verify_project | WorkspaceResource | 159,180 | 159,180 | class WorkspaceResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
cluster_type = self.verify_project()
if not cluster_type:
cluster_type = query_arg.get('cluster_type', [None])
if cluster_type:
... | class WorkspaceResource(GenericResource):
@classmethod
@safe_db_query
def collection(self, query_arg, meta, user, **kwargs):
cluster_type = self.verify_project()
if not cluster_type:
cluster_type = query_arg.get('cluster_type', [None])
if cluster_type:
... | project_type = get_project_type()
if project_type != ProjectType.MAIN and os.getenv(MANAGE_ENV_VAR) != '1':
error = ApiError.RESOURCE_ERROR.copy()
error.update(message='This project is ineligible for workspace management.')
raise ApiError(error)
if project_ty... | project_type = get_project_type()
if project_type != ProjectType.MAIN and os.getenv(MANAGE_ENV_VAR) != '1':
error = ApiError.RESOURCE_ERROR.copy()
error.update(message='This project is ineligible for workspace management.')
raise ApiError(error)
if project_ty... | 69 | 1,214 | 296 | 1,510 | import os
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.manage import get_instances, get_workspaces
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.cluster_manager.workspace.kubernetes import KubernetesWo... | import os
from mage_ai.api.errors import ApiError
from mage_ai.api.resources.GenericResource import GenericResource
from mage_ai.cluster_manager.manage import get_instances, get_workspaces
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.cluster_manager.workspace.kubernetes import KubernetesWo... |
20,501 | /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/api/resources/shared/collections.py | 5,6 | 1,21 | limit_collection | 6,21 | 6,21 | from mage_ai.api.constants import META_KEY_LIMIT, META_KEY_OFFSET
from typing import Dict, List
def limit_collection(results: List, query: Dict) -> List:
FILL_FUNC_BODY | from mage_ai.api.constants import META_KEY_LIMIT, META_KEY_OFFSET
from typing import Dict, List
def limit_collection(results: List, query: Dict) -> List:
FILL_FUNC_BODY | limit = query.get(META_KEY_LIMIT, [None])
if limit:
limit = limit[0]
offset = query.get(META_KEY_OFFSET, [None])
if offset:
offset = offset[0]
if limit is not None:
results = results.limit(limit)
if offset is not None:
results = results.offset(offset)
retu... | limit = query.get(META_KEY_LIMIT, [None])
if limit:
limit = limit[0]
offset = query.get(META_KEY_OFFSET, [None])
if offset:
offset = offset[0]
if limit is not None:
results = results.limit(limit)
if offset is not None:
results = results.offset(offset)
retu... | 36 | 66 | 123 | 189 | from mage_ai.api.constants import META_KEY_LIMIT, META_KEY_OFFSET
from typing import Dict, List
def limit_collection(results: List, query: Dict) -> List:
FILL_FUNC_BODY | from mage_ai.api.constants import META_KEY_LIMIT, META_KEY_OFFSET
from typing import Dict, List
def limit_collection(results: List, query: Dict) -> List:
FILL_FUNC_BODY | |
20,502 | /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/api/resources/shared/collective_loaders.py | 36,37 | 1,90 | build_load_select | 37,58 | 37,58 | import importlib
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.array import find
def build_load(associated_resource_class, **kwargs):
associated_id_column_name = '{}_id'.format(kwargs.get(
'attribute', associated_resource_class.resource_name_singular()), )
def _load(reso... | import importlib
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.array import find
def build_load(associated_resource_class, **kwargs):
associated_id_column_name = '{}_id'.format(kwargs.get(
'attribute', associated_resource_class.resource_name_singular()), )
def _load(reso... | associated_id_column_name = '{}_id'.format(
kwargs.get('attribute', current_resource.resource_name_singular()),
)
def _load(resource):
ids = [r.id for r in resource.result_set()]
query = {}
query[f'{associated_id_column_name}__in'] = ids
query_set = associated_resour... | associated_id_column_name = '{}_id'.format(
kwargs.get('attribute', current_resource.resource_name_singular()),
)
def _load(resource):
ids = [r.id for r in resource.result_set()]
query = {}
query[f'{associated_id_column_name}__in'] = ids
query_set = associated_resour... | 36 | 569 | 222 | 791 | import importlib
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.array import find
def build_load(associated_resource_class, **kwargs):
associated_id_column_name = '{}_id'.format(kwargs.get(
'attribute', associated_resource_class.resource_name_singular()), )
def _load(reso... | import importlib
from mage_ai.orchestration.db.models.oauth import User
from mage_ai.shared.array import find
def build_load(associated_resource_class, **kwargs):
associated_id_column_name = '{}_id'.format(kwargs.get(
'attribute', associated_resource_class.resource_name_singular()), )
def _load(reso... | |
20,503 | /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/api/result_set.py | 17,18 | 8,33 | add_results | ResultSet | 18,33 | 18,33 | class ResultSet(UserList):
def __init__(self, results: List[Resource] = None):
self.context = ApiContext()
self.data = []
self.metadata = {}
if results is not None:
self.add_results(results)
def add_results(self, results: List[Resource]) -> None:
FILL_FUNC_BODY | class ResultSet(UserList):
def __init__(self, results: List[Resource] = None):
self.context = ApiContext()
self.data = []
self.metadata = {}
if results is not None:
self.add_results(results)
def add_results(self, results: List[Resource]) -> None:
FILL_FUNC_BODY | for r in results:
if issubclass(r.__class__, Resource):
key = r.__class__.__name__
if not r.model_options.get('result_sets', None):
r.model_options['result_sets'] = {}
existing_result_set = r.model_options['result_sets'].get(
... | for r in results:
if issubclass(r.__class__, Resource):
key = r.__class__.__name__
if not r.model_options.get('result_sets', None):
r.model_options['result_sets'] = {}
existing_result_set = r.model_options['result_sets'].get(
... | 37 | 98 | 186 | 284 | from collections import UserList
from typing import List
from mage_ai.api.api_context import ApiContext
from mage_ai.api.resources.Resource import Resource
class ResultSet(UserList):
def __init__(self, results: List[Resource] = None):
self.context = ApiContext()
self.data = []
self.metada... | from collections import UserList
from typing import List
from mage_ai.api.api_context import ApiContext
from mage_ai.api.resources.Resource import Resource
class ResultSet(UserList):
def __init__(self, results: List[Resource] = None):
self.context = ApiContext()
self.data = []
self.metada... |
20,504 | /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/api/utils.py | 92,97 | 1,157 | has_at_least_viewer_role | 97,106 | 97,106 | from datetime import datetime
from typing import List, Tuple
from mage_ai.api.errors import ApiError
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db.models.oauth import (
Oauth2AccessToken,
Permission,
Role,
User,
)
from mage_ai.settings import (
DISABLE_NOTEBOOK_ED... | from datetime import datetime
from typing import List, Tuple
from mage_ai.api.errors import ApiError
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db.models.oauth import (
Oauth2AccessToken,
Permission,
Role,
User,
)
from mage_ai.settings import (
DISABLE_NOTEBOOK_ED... | return not user or \
(not REQUIRE_USER_AUTHENTICATION and not is_test()) or \
is_owner(user, entity, entity_id) or \
has_at_least_admin_role(user, entity, entity_id) or \
has_at_least_editor_role(user, entity, entity_id) or \
(user.roles and user.roles & 4 != 0) or \
... | return not user or \
(not REQUIRE_USER_AUTHENTICATION and not is_test()) or \
is_owner(user, entity, entity_id) or \
has_at_least_admin_role(user, entity, entity_id) or \
has_at_least_editor_role(user, entity, entity_id) or \
(user.roles and user.roles & 4 != 0) or \
... | 44 | 1,530 | 151 | 1,681 | from datetime import datetime
from typing import List, Tuple
from mage_ai.api.errors import ApiError
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db.models.oauth import (
Oauth2AccessToken,
Permission,
Role,
User,
)
from mage_ai.settings import (
DISABLE_NOTEBOOK_ED... | from datetime import datetime
from typing import List, Tuple
from mage_ai.api.errors import ApiError
from mage_ai.orchestration.constants import Entity
from mage_ai.orchestration.db.models.oauth import (
Oauth2AccessToken,
Permission,
Role,
User,
)
from mage_ai.settings import (
DISABLE_NOTEBOOK_ED... | |
20,505 | /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/authentication/oauth/constants.py | 38,39 | 1,44 | get_ghe_hostname | 39,44 | 39,44 | from enum import Enum
from typing import Optional
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import GHE_HOSTNAME
ACTIVE_DIRECTORY_CLIENT_ID = '51aec820-9d49-40a9-b046-17c1f28f620d'
GITHUB_CLIENT_ID = '8577f13ddc81e2848b07'
GITHUB_STATE = '1337'
class ProviderName(str, Enum):
ACT... | from enum import Enum
from typing import Optional
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import GHE_HOSTNAME
ACTIVE_DIRECTORY_CLIENT_ID = '51aec820-9d49-40a9-b046-17c1f28f620d'
GITHUB_CLIENT_ID = '8577f13ddc81e2848b07'
GITHUB_STATE = '1337'
class ProviderName(str, Enum):
ACT... | ghe_hostname = get_settings_value(GHE_HOSTNAME)
if ghe_hostname and not ghe_hostname.startswith('http'):
ghe_hostname = f'https://{ghe_hostname}'
return ghe_hostname
| ghe_hostname = get_settings_value(GHE_HOSTNAME)
if ghe_hostname and not ghe_hostname.startswith('http'):
ghe_hostname = f'https://{ghe_hostname}'
return ghe_hostname
| 13 | 410 | 77 | 487 | from enum import Enum
from typing import Optional
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import GHE_HOSTNAME
ACTIVE_DIRECTORY_CLIENT_ID = '51aec820-9d49-40a9-b046-17c1f28f620d'
GITHUB_CLIENT_ID = '8577f13ddc81e2848b07'
GITHUB_STATE = '1337'
class ProviderName(str, Enum):
ACT... | from enum import Enum
from typing import Optional
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import GHE_HOSTNAME
ACTIVE_DIRECTORY_CLIENT_ID = '51aec820-9d49-40a9-b046-17c1f28f620d'
GITHUB_CLIENT_ID = '8577f13ddc81e2848b07'
GITHUB_STATE = '1337'
class ProviderName(str, Enum):
ACT... | |
20,506 | /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/authentication/oauth/utils.py | 129,130 | 1,184 | add_access_token_to_query | 150,184 | 130,184 | from datetime import datetime, timedelta
from typing import Awaitable, Dict, List, Optional
from mage_ai.authentication.oauth2 import generate_access_token
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oauth import OauthProvider
from mage_ai.orchestration.db impo... | from datetime import datetime, timedelta
from typing import Awaitable, Dict, List, Optional
from mage_ai.authentication.oauth2 import generate_access_token
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oauth import OauthProvider
from mage_ai.orchestration.db impo... | access_token = data.get('access_token')
if access_token:
query['access_token'] = access_token
else:
error = data.get('error')
error_description = data.get('error_description')
error_uri = data.get('error_uri')
if error:
error = '. '.join(
... | """
Add an access token or error details to a query dictionary.
1. If an access token exists, it is added to the query dictionary.
2. If there's no access token, it checks for error-related information in the data dictionary:
- 'error': The error code or message.
- 'error_description': A de... | 64 | 1,474 | 260 | 1,734 | from datetime import datetime, timedelta
from typing import Awaitable, Dict, List, Optional
from mage_ai.authentication.oauth2 import generate_access_token
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oauth import OauthProvider
from mage_ai.orchestration.db impo... | from datetime import datetime, timedelta
from typing import Awaitable, Dict, List, Optional
from mage_ai.authentication.oauth2 import generate_access_token
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oauth import OauthProvider
from mage_ai.orchestration.db impo... | |
20,507 | /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/authentication/operation_history/models.py | 39,40 | 20,48 | to_dict | OperationHistory | 40,48 | 40,48 | @dataclass
class OperationHistory:
operation: str
resource: Dict = field(default_factory=dict)
timestamp: int = None
user: str = None
def __init__(
self,
operation: OperationType,
resource: Dict,
timestamp: int = None,
user: str = None,
):
self.op... | @dataclass
class OperationHistory:
operation: str
resource: Dict = field(default_factory=dict)
timestamp: int = None
user: str = None
def __init__(
self,
operation: OperationType,
resource: Dict,
timestamp: int = None,
user: str = None,
):
self.op... | return dict(
operation=self.operation,
resource=self.resource,
timestamp=self.timestamp,
user=self.user,
)
| return dict(
operation=self.operation,
resource=self.resource,
timestamp=self.timestamp,
user=self.user,
)
| 7 | 142 | 50 | 192 | import json
import os
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import (
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
MAGE... | import json
import os
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import (
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
MAGE... |
20,508 | /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/authentication/operation_history/models.py | 93,94 | 48,171 | build_file_path | OperationHistoryReader | 94,107 | 94,107 | class OperationHistoryReader:
def __init__(self, repo_config=None, repo_path: str = None):
self.root_project = project_platform_activated()
self.repo_path = repo_path or get_repo_path(root_project=self.root_project)
if repo_config is None:
self.repo_config = get_repo_config(
... | class OperationHistoryReader:
def __init__(self, repo_config=None, repo_path: str = None):
self.root_project = project_platform_activated()
self.repo_path = repo_path or get_repo_path(root_project=self.root_project)
if repo_config is None:
self.repo_config = get_repo_config(
... | dir_path = os.getenv(
MAGE_OPERATION_HISTORY_DIRECTORY_ENVIRONMENT_VARIABLE_NAME,
) or os.path.join(
self.directory_name,
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
)
filename = datetime.fromtimestamp(
timestamp or int(datetime.utcnow().tim... | dir_path = os.getenv(
MAGE_OPERATION_HISTORY_DIRECTORY_ENVIRONMENT_VARIABLE_NAME,
) or os.path.join(
self.directory_name,
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
)
filename = datetime.fromtimestamp(
timestamp or int(datetime.utcnow().tim... | 20 | 974 | 149 | 1,123 | import json
import os
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import (
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
MAGE... | import json
import os
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import (
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT,
MAGE... |
20,509 | /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/authentication/operation_history/utils.py | 36,41 | 1,99 | record_detail | 41,53 | 41,53 | from typing import List
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import ResourceType
from mage_ai.authentication.operation_history.models import (
OperationHistory,
OperationHistoryReader,
)
def record_create(
resource_type: Resour... | from typing import List
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import ResourceType
from mage_ai.authentication.operation_history.models import (
OperationHistory,
OperationHistoryReader,
)
def record_create(
resource_type: Resour... | reader = OperationHistoryReader()
model = reader.create(
operation=OperationType.DETAIL.value,
resource_type=resource_type,
resource_uuid=resource_uuid,
user=user,
)
reader.save(model)
return model
| reader = OperationHistoryReader()
model = reader.create(
operation=OperationType.DETAIL.value,
resource_type=resource_type,
resource_uuid=resource_uuid,
user=user,
)
reader.save(model)
return model
| 14 | 663 | 85 | 748 | from typing import List
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import ResourceType
from mage_ai.authentication.operation_history.models import (
OperationHistory,
OperationHistoryReader,
)
def record_create(
resource_type: Resour... | from typing import List
from mage_ai.api.operations.constants import OperationType
from mage_ai.authentication.operation_history.constants import ResourceType
from mage_ai.authentication.operation_history.models import (
OperationHistory,
OperationHistoryReader,
)
def record_create(
resource_type: Resour... | |
20,510 | /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/authentication/providers/oauth.py | 59,60 | 5,73 | get_refresh_token_response | OauthProvider | 72,73 | 60,73 | class OauthProvider(ABC):
"""
Base class for oauth authentication. This provider will be used for oauth authentication flows.
The current oauth for Mage is as follows:
1. Mage client will make a request to the server to get the auth url to get the authorization
code for the provider. (get_auth_u... | class OauthProvider(ABC):
"""
Base class for oauth authentication. This provider will be used for oauth authentication flows.
The current oauth for Mage is as follows:
1. Mage client will make a request to the server to get the auth url to get the authorization
code for the provider. (get_auth_u... | raise NotImplementedError()
| """
This method should call the oauth provider with the refresh token and return
a dictionary containing an access token for the user.
Args:
refresh_token (str): the refresh token to use to try to get a new access token
Returns:
Dict: a dict with the fol... | 2 | 719 | 10 | 729 | from abc import ABC, abstractmethod
from typing import Awaitable, Dict
class OauthProvider(ABC):
"""
Base class for oauth authentication. This provider will be used for oauth authentication flows.
The current oauth for Mage is as follows:
1. Mage client will make a request to the server to get the au... | from abc import ABC, abstractmethod
from typing import Awaitable, Dict
class OauthProvider(ABC):
"""
Base class for oauth authentication. This provider will be used for oauth authentication flows.
The current oauth for Mage is as follows:
1. Mage client will make a request to the server to get the au... |
20,511 | /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/authentication/providers/okta.py | 28,29 | 9,44 | __validate | OktaProvider | 29,44 | 29,44 | class OktaProvider(
OidcProvider
): # Okta configuration uses OIDC so we can just subclass the OidcProvider
provider = ProviderName.OKTA
def __init__(self):
self.hostname = get_settings_value(OKTA_DOMAIN_URL)
self.client_id = get_settings_value(OKTA_CLIENT_ID)
self.client_secret = ... | class OktaProvider(
OidcProvider
): # Okta configuration uses OIDC so we can just subclass the OidcProvider
provider = ProviderName.OKTA
def __init__(self):
self.hostname = get_settings_value(OKTA_DOMAIN_URL)
self.client_id = get_settings_value(OKTA_CLIENT_ID)
self.client_secret = ... | if not self.parsed_url.netloc:
raise ValueError(
'Okta hostname is empty. '
'Make sure the OKTA_DOMAIN_URL environment variable is set.'
)
if not self.client_id:
raise ValueError(
'Okta client id is empty. '
... | if not self.parsed_url.netloc:
raise ValueError(
'Okta hostname is empty. '
'Make sure the OKTA_DOMAIN_URL environment variable is set.'
)
if not self.client_id:
raise ValueError(
'Okta client id is empty. '
... | 59 | 252 | 165 | 417 | from urllib.parse import unquote, urlparse
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oidc import OidcProvider
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, OKTA_DOMAIN_URL
class OktaPro... | from urllib.parse import unquote, urlparse
from mage_ai.authentication.oauth.constants import ProviderName
from mage_ai.authentication.providers.oidc import OidcProvider
from mage_ai.settings import get_settings_value
from mage_ai.settings.keys import OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, OKTA_DOMAIN_URL
class OktaPro... |
20,512 | /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/authentication/providers/utils.py | 6,7 | 1,13 | get_base_url | 7,13 | 7,13 | from urllib.parse import unquote, urlparse
from mage_ai.settings import ROUTES_BASE_PATH
def get_base_url(url: str) -> str:
FILL_FUNC_BODY | from urllib.parse import unquote, urlparse
from mage_ai.settings import ROUTES_BASE_PATH
def get_base_url(url: str) -> str:
FILL_FUNC_BODY | parsed_url = urlparse(unquote(url))
base_url = parsed_url.scheme + '://' + parsed_url.netloc
if ROUTES_BASE_PATH:
base_url += f'/{ROUTES_BASE_PATH}'
return base_url
| parsed_url = urlparse(unquote(url))
base_url = parsed_url.scheme + '://' + parsed_url.netloc
if ROUTES_BASE_PATH:
base_url += f'/{ROUTES_BASE_PATH}'
return base_url
| 17 | 58 | 77 | 135 | from urllib.parse import unquote, urlparse
from mage_ai.settings import ROUTES_BASE_PATH
def get_base_url(url: str) -> str:
FILL_FUNC_BODY | from urllib.parse import unquote, urlparse
from mage_ai.settings import ROUTES_BASE_PATH
def get_base_url(url: str) -> str:
FILL_FUNC_BODY | |
20,513 | /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/cache/base.py | 43,44 | 13,86 | get | BaseCache | 44,55 | 44,55 | class BaseCache():
cache_key = None
def __init__(self, repo_path: str = None, repo_config=None, root_project: bool = True):
self.root_project = root_project
self.repo_path = repo_path or get_repo_path(root_project=self.root_project)
if repo_config is None:
self.repo_config ... | class BaseCache():
cache_key = None
def __init__(self, repo_path: str = None, repo_config=None, root_project: bool = True):
self.root_project = root_project
self.repo_path = repo_path or get_repo_path(root_project=self.root_project)
if repo_config is None:
self.repo_config ... | if refresh or not self._temp_data:
self._temp_data = self.storage.read_json_file(
self.build_path(key or self.cache_key),
None,
)
if self._temp_data:
return self._temp_data
return self._temp_data
| if refresh or not self._temp_data:
self._temp_data = self.storage.read_json_file(
self.build_path(key or self.cache_key),
None,
)
if self._temp_data:
return self._temp_data
return self._temp_data
| 19 | 659 | 92 | 751 | import os
from typing import Any, Dict, List, Union
from mage_ai.cache.constants import (
MAGE_CACHE_DIRECTORY_DEFAULT,
MAGE_CACHE_DIRECTORY_ENVIRONMENT_VARIABLE_NAME,
)
from mage_ai.data_preparation.repo_manager import RepoConfig, get_repo_config
from mage_ai.data_preparation.storage.local_storage import Loca... | import os
from typing import Any, Dict, List, Union
from mage_ai.cache.constants import (
MAGE_CACHE_DIRECTORY_DEFAULT,
MAGE_CACHE_DIRECTORY_ENVIRONMENT_VARIABLE_NAME,
)
from mage_ai.data_preparation.repo_manager import RepoConfig, get_repo_config
from mage_ai.data_preparation.storage.local_storage import Loca... |
20,514 | /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/cache/dbt/constants.py | 28,29 | 1,35 | infer_file_type | 29,35 | 29,35 | from enum import Enum
from mage_ai.data_preparation.models.constants import (
BLOCK_TYPE_DIRECTORY_NAME,
PIPELINES_FOLDER,
BlockType,
)
from mage_ai.shared.hash import merge_dict
IGNORE_DIRECTORY_NAMES = merge_dict(
{v: k for k, v in BLOCK_TYPE_DIRECTORY_NAME.items() if k is not BlockType.DBT},
{
... | from enum import Enum
from mage_ai.data_preparation.models.constants import (
BLOCK_TYPE_DIRECTORY_NAME,
PIPELINES_FOLDER,
BlockType,
)
from mage_ai.shared.hash import merge_dict
IGNORE_DIRECTORY_NAMES = merge_dict(
{v: k for k, v in BLOCK_TYPE_DIRECTORY_NAME.items() if k is not BlockType.DBT},
{
... | if file_path.endswith('.sql'):
return FileType.MODEL
elif file_path.endswith(PROFILES_FILENAME):
return FileType.PROFILES
elif any([file_path.endswith(filename) for filename in PROJECT_FILENAMES]):
return FileType.PROJECT
| if file_path.endswith('.sql'):
return FileType.MODEL
elif file_path.endswith(PROFILES_FILENAME):
return FileType.PROFILES
elif any([file_path.endswith(filename) for filename in PROJECT_FILENAMES]):
return FileType.PROJECT
| 16 | 276 | 88 | 364 | from enum import Enum
from mage_ai.data_preparation.models.constants import (
BLOCK_TYPE_DIRECTORY_NAME,
PIPELINES_FOLDER,
BlockType,
)
from mage_ai.shared.hash import merge_dict
IGNORE_DIRECTORY_NAMES = merge_dict(
{v: k for k, v in BLOCK_TYPE_DIRECTORY_NAME.items() if k is not BlockType.DBT},
{
... | from enum import Enum
from mage_ai.data_preparation.models.constants import (
BLOCK_TYPE_DIRECTORY_NAME,
PIPELINES_FOLDER,
BlockType,
)
from mage_ai.shared.hash import merge_dict
IGNORE_DIRECTORY_NAMES = merge_dict(
{v: k for k, v in BLOCK_TYPE_DIRECTORY_NAME.items() if k is not BlockType.DBT},
{
... | |
20,515 | /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/cache/file.py | 35,37 | 18,127 | initialize_cache_with_settings | FileCache | 37,76 | 37,76 | class FileCache(BaseCache):
cache_key = CACHE_KEY_FILES
@classmethod
def initialize_cache(
self,
absolute_paths: List[str],
replace: bool = False,
) -> 'FileCache':
repo_path = get_repo_path(root_project=True)
cache = self(repo_path=repo_path)
if replace... | class FileCache(BaseCache):
cache_key = CACHE_KEY_FILES
@classmethod
def initialize_cache(
self,
absolute_paths: List[str],
replace: bool = False,
) -> 'FileCache':
repo_path = get_repo_path(root_project=True)
cache = self(repo_path=repo_path)
if replace... | # Include all projects from platform
# Relative to the base repo path
base_path = base_repo_path()
paths = []
paths_excludes = []
projects = []
projects_excludes = []
# Include directories listed in command center settings and exclude those listed.
... | # Include all projects from platform
# Relative to the base repo path
base_path = base_repo_path()
paths = []
paths_excludes = []
projects = []
projects_excludes = []
# Include directories listed in command center settings and exclude those listed.
... | 111 | 686 | 421 | 1,107 | import os
from pathlib import Path
from typing import Any, List
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_FILES
from mage_ai.command_center.models import CommandCenterSettings
from mage_ai.settings import MAX_FILE_CACHE_SIZE
from mage_ai.settings.platform import build_repo_... | import os
from pathlib import Path
from typing import Any, List
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_FILES
from mage_ai.command_center.models import CommandCenterSettings
from mage_ai.settings import MAX_FILE_CACHE_SIZE
from mage_ai.settings.platform import build_repo_... |
20,516 | /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/cache/pipeline.py | 162,163 | 13,198 | initialize_cache_for_models | PipelineCache | 163,198 | 163,198 | class PipelineCache(BaseCache):
cache_key = CACHE_KEY_PIPELINE_DETAILS_MAPPING
@classmethod
async def initialize_cache(
self,
replace: bool = False,
pipelines: List[Dict] = None,
) -> 'PipelineCache':
cache = self()
if replace or not cache.exists():
a... | class PipelineCache(BaseCache):
cache_key = CACHE_KEY_PIPELINE_DETAILS_MAPPING
@classmethod
async def initialize_cache(
self,
replace: bool = False,
pipelines: List[Dict] = None,
) -> 'PipelineCache':
cache = self()
if replace or not cache.exists():
a... | if pipelines is None:
from mage_ai.data_preparation.models.pipeline import Pipeline
pipeline_uuids_and_repo_path = Pipeline.get_all_pipelines_all_projects(
self.repo_path,
include_repo_path=True,
)
pipeline_dicts = await asyncio.g... | if pipelines is None:
from mage_ai.data_preparation.models.pipeline import Pipeline
pipeline_uuids_and_repo_path = Pipeline.get_all_pipelines_all_projects(
self.repo_path,
include_repo_path=True,
)
pipeline_dicts = await asyncio.g... | 80 | 1,356 | 367 | 1,723 | import asyncio
from datetime import datetime
from typing import Any, Dict, List, Union
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_PIPELINE_DETAILS_MAPPING
from mage_ai.cache.utils import build_pipeline_dict, group_models_by_keys
from mage_ai.data_preparation.models.utils imp... | import asyncio
from datetime import datetime
from typing import Any, Dict, List, Union
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_PIPELINE_DETAILS_MAPPING
from mage_ai.cache.utils import build_pipeline_dict, group_models_by_keys
from mage_ai.data_preparation.models.utils imp... |
20,517 | /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/cache/tag.py | 152,153 | 14,196 | initialize_cache_for_all_objects | TagCache | 153,196 | 153,196 | class TagCache(BaseCache):
cache_key = CACHE_KEY_TAGS_TO_OBJECT_MAPPING
@classmethod
async def initialize_cache(self, replace: bool = False) -> 'TagCache':
cache = self()
if replace or not cache.exists():
await cache.initialize_cache_for_all_objects()
return cache
... | class TagCache(BaseCache):
cache_key = CACHE_KEY_TAGS_TO_OBJECT_MAPPING
@classmethod
async def initialize_cache(self, replace: bool = False) -> 'TagCache':
cache = self()
if replace or not cache.exists():
await cache.initialize_cache_for_all_objects()
return cache
... | from mage_ai.data_preparation.models.pipeline import Pipeline
pipeline_uuids_and_repo_path = Pipeline.get_all_pipelines_all_projects(
self.repo_path,
include_repo_path=True,
)
pipeline_dicts = await asyncio.gather(
*[Pipeline.load_metadata(
... | from mage_ai.data_preparation.models.pipeline import Pipeline
pipeline_uuids_and_repo_path = Pipeline.get_all_pipelines_all_projects(
self.repo_path,
include_repo_path=True,
)
pipeline_dicts = await asyncio.gather(
*[Pipeline.load_metadata(
... | 94 | 1,333 | 465 | 1,798 | import asyncio
import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_TAGS_TO_OBJECT_MAPPING
from mage_ai.cache.utils import build_pipeline_dict
KEY_FOR_PIPELINES = 'Pipeline'
NO_TAGS_QUERY = 'no_tags'
class TagCac... | import asyncio
import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.base import BaseCache
from mage_ai.cache.constants import CACHE_KEY_TAGS_TO_OBJECT_MAPPING
from mage_ai.cache.utils import build_pipeline_dict
KEY_FOR_PIPELINES = 'Pipeline'
NO_TAGS_QUERY = 'no_tags'
class TagCac... |
20,518 | /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/cache/utils.py | 55,61 | 1,125 | build_pipeline_dict | 61,107 | 61,107 | from datetime import datetime
from typing import Callable, Dict, List, Union
from mage_ai.shared.hash import extract, merge_dict
PIPELINE_KEYS = [
'created_at',
'description',
'name',
'tags',
'type',
'uuid',
]
BLOCK_KEYS = [
'downstream_blocks',
'language',
'name',
'type',
... | from datetime import datetime
from typing import Callable, Dict, List, Union
from mage_ai.shared.hash import extract, merge_dict
PIPELINE_KEYS = [
'created_at',
'description',
'name',
'tags',
'type',
'uuid',
]
BLOCK_KEYS = [
'downstream_blocks',
'language',
'name',
'type',
... | pipeline_output_dict = dict(
created_at=None,
description=None,
name=None,
tags=None,
type=None,
uuid=None,
)
if repo_path:
pipeline_output_dict['repo_path'] = repo_path
if isinstance(pipeline, dict):
pipeline_output_dict.update(extract(p... | pipeline_output_dict = dict(
created_at=None,
description=None,
name=None,
tags=None,
type=None,
uuid=None,
)
if repo_path:
pipeline_output_dict['repo_path'] = repo_path
if isinstance(pipeline, dict):
pipeline_output_dict.update(extract(p... | 112 | 608 | 511 | 1,119 | from datetime import datetime
from typing import Callable, Dict, List, Union
from mage_ai.shared.hash import extract, merge_dict
PIPELINE_KEYS = [
'created_at',
'description',
'name',
'tags',
'type',
'uuid',
]
BLOCK_KEYS = [
'downstream_blocks',
'language',
'name',
'type',
... | from datetime import datetime
from typing import Callable, Dict, List, Union
from mage_ai.shared.hash import extract, merge_dict
PIPELINE_KEYS = [
'created_at',
'description',
'name',
'tags',
'type',
'uuid',
]
BLOCK_KEYS = [
'downstream_blocks',
'language',
'name',
'type',
... | |
20,519 | /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/cli/utils.py | 6,7 | 1,40 | parse_runtime_variables | 16,27 | 7,27 | import json
import traceback
from typing import Any, Dict, Union
def parse_runtime_variables(variables_str: str) -> Dict[str, Any]:
FILL_FUNC_BODYdef get_value(value: Union[str, None]) -> Any:
"""
Returns parsed value.
If the string is a valid JSON object, deserializes it to a Python object.
Otherwis... | import json
import traceback
from typing import Any, Dict, Union
def parse_runtime_variables(variables_str: str) -> Dict[str, Any]:
"""
Returns a dictionary of variable to parsed values.
Args:
variables_str (str): The variables json string
Returns:
Dict[str, Any]: The parsed variable... | vars_parsed = dict()
if not variables_str:
return vars_parsed
try:
vars_parsed = json.loads(variables_str)
except Exception:
traceback.print_exc()
return vars_parsed
| """
Returns a dictionary of variable to parsed values.
Args:
variables_str (str): The variables json string
Returns:
Dict[str, Any]: The parsed variables dictionary
"""
vars_parsed = dict()
if not variables_str:
return vars_parsed
try:
vars_parsed = jso... | 17 | 209 | 84 | 293 | import json
import traceback
from typing import Any, Dict, Union
def parse_runtime_variables(variables_str: str) -> Dict[str, Any]:
FILL_FUNC_BODYdef get_value(value: Union[str, None]) -> Any:
"""
Returns parsed value.
If the string is a valid JSON object, deserializes it to a Python object.
Otherwis... | import json
import traceback
from typing import Any, Dict, Union
def parse_runtime_variables(variables_str: str) -> Dict[str, Any]:
"""
Returns a dictionary of variable to parsed values.
Args:
variables_str (str): The variables json string
Returns:
Dict[str, Any]: The parsed variable... | |
20,520 | /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/cluster_manager/aws/ecs_task_manager.py | 152,153 | 13,175 | __get_network_interfaces | EcsTaskManager | 153,175 | 153,175 | class EcsTaskManager:
def __init__(self, cluster_name):
self.cluster_name = cluster_name
self.metadata_file = os.path.join(
os.getcwd(),
'instance_metadata.json',
)
if not os.path.exists(self.metadata_file):
self.instance_metadata = {}
@prop... | class EcsTaskManager:
def __init__(self, cluster_name):
self.cluster_name = cluster_name
self.metadata_file = os.path.join(
os.getcwd(),
'instance_metadata.json',
)
if not os.path.exists(self.metadata_file):
self.instance_metadata = {}
@prop... | task_mapping = dict()
for task in tasks:
nii = self.__get_network_interface_id(task)
if nii is not None:
task_mapping[task['taskArn']] = nii
network_interface_ids = list(task_mapping.values())
network_interfaces = ec2_client.describe_network_inte... | task_mapping = dict()
for task in tasks:
nii = self.__get_network_interface_id(task)
if nii is not None:
task_mapping[task['taskArn']] = nii
network_interface_ids = list(task_mapping.values())
network_interfaces = ec2_client.describe_network_inte... | 52 | 1,335 | 229 | 1,564 | import json
import os
from functools import reduce
from typing import Dict, List
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
from mage_ai.services.aws.ecs.ecs import list_services, list_tasks, run_task, stop_task
from mage_ai.shared.array import find
from... | import json
import os
from functools import reduce
from typing import Dict, List
from mage_ai.services.aws import get_aws_boto3_client
from mage_ai.services.aws.ecs.config import EcsConfig
from mage_ai.services.aws.ecs.ecs import list_services, list_tasks, run_task, stop_task
from mage_ai.shared.array import find
from... |
20,521 | /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/cluster_manager/aws/emr_cluster_manager.py | 21,22 | 17,98 | list_clusters | EmrClusterManager | 22,39 | 22,39 | class EmrClusterManager(ClusterManager):
def __init__(self):
self.active_cluster_id = None
def list_clusters(self):
FILL_FUNC_BODY def create_cluster(self, repo_path: str, emr_config: Dict = None):
emr_config = EmrConfig.load(
config=merge_dict(get_repo_config().emr_config or dic... | class EmrClusterManager(ClusterManager):
def __init__(self):
self.active_cluster_id = None
def list_clusters(self):
FILL_FUNC_BODY def create_cluster(self, repo_path: str, emr_config: Dict = None):
emr_config = EmrConfig.load(
config=merge_dict(get_repo_config().emr_config or dic... | clusters = list_clusters()['Clusters']
valid_clusters = []
for c in clusters:
cluster_info = describe_cluster(c['Id'])
cluster_tags = cluster_info['Tags']
if find(
lambda t: t['Key'] == 'name' and t['Value'] == CLUSTER_NAME,
clu... | clusters = list_clusters()['Clusters']
valid_clusters = []
for c in clusters:
cluster_info = describe_cluster(c['Id'])
cluster_tags = cluster_info['Tags']
if find(
lambda t: t['Key'] == 'name' and t['Value'] == CLUSTER_NAME,
clu... | 43 | 691 | 191 | 882 | import json
import os
from pathlib import Path
from typing import Dict
from mage_ai.cluster_manager.cluster_manager import ClusterManager
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import describe_cluster, li... | import json
import os
from pathlib import Path
from typing import Dict
from mage_ai.cluster_manager.cluster_manager import ClusterManager
from mage_ai.data_preparation.repo_manager import get_repo_config
from mage_ai.services.aws.emr.config import EmrConfig
from mage_ai.services.aws.emr.emr import describe_cluster, li... |
20,522 | /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/cluster_manager/config.py | 80,82 | 74,89 | parse_config | LifecycleConfig | 82,89 | 82,89 | @dataclass
class LifecycleConfig(BaseConfig):
termination_policy: TerminationPolicy = None
pre_start_script_path: str = None
post_start: PostStart = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | @dataclass
class LifecycleConfig(BaseConfig):
termination_policy: TerminationPolicy = None
pre_start_script_path: str = None
post_start: PostStart = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | pre_start_script_path = config.get('pre_start_script_path')
if pre_start_script_path and not os.path.isabs(pre_start_script_path):
config['pre_start_script_path'] = os.path.join(
get_repo_path(root_project=True), pre_start_script_path
)
return config
| pre_start_script_path = config.get('pre_start_script_path')
if pre_start_script_path and not os.path.isabs(pre_start_script_path):
config['pre_start_script_path'] = os.path.join(
get_repo_path(root_project=True), pre_start_script_path
)
return config
| 16 | 87 | 104 | 191 | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... |
20,523 | /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/cluster_manager/config.py | 63,65 | 58,74 | parse_config | PostStart | 65,74 | 65,74 | @dataclass
class PostStart(BaseConfig):
command: List[str] = None
hook_path: str = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | @dataclass
class PostStart(BaseConfig):
command: List[str] = None
hook_path: str = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | hook_path = config.get('hook_path')
if hook_path and not os.path.isabs(hook_path):
config['hook_path'] = os.path.join(
get_repo_path(root_project=True), hook_path
)
return config
| hook_path = config.get('hook_path')
if hook_path and not os.path.isabs(hook_path):
config['hook_path'] = os.path.join(
get_repo_path(root_project=True), hook_path
)
return config
| 16 | 69 | 84 | 153 | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... |
20,524 | /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/cluster_manager/config.py | 15,17 | 10,26 | parse_config | WorkspaceConfig | 17,26 | 17,26 | @dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
project_uuid: str = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | @dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
project_uuid: str = None
@classmethod
def parse_config(self, config: Dict = None) -> Dict:
FILL_FUNC_BODY | lifecycle_config = config.get('lifecycle_config')
if lifecycle_config and type(lifecycle_config) is dict:
config['lifecycle_config'] = LifecycleConfig.load(config=lifecycle_config)
all_fields = fields(self)
keys = [field.name for field in all_fields]
return extract(c... | lifecycle_config = config.get('lifecycle_config')
if lifecycle_config and type(lifecycle_config) is dict:
config['lifecycle_config'] = LifecycleConfig.load(config=lifecycle_config)
all_fields = fields(self)
keys = [field.name for field in all_fields]
return extract(c... | 25 | 77 | 115 | 192 | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... | import os
from dataclasses import dataclass, fields
from typing import Dict, List
from mage_ai.settings.repo import get_repo_path
from mage_ai.shared.config import BaseConfig
from mage_ai.shared.hash import extract
@dataclass
class WorkspaceConfig(BaseConfig):
lifecycle_config: 'LifecycleConfig' = None
proje... |
20,525 | /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/cluster_manager/manage.py | 94,95 | 1,153 | check_auto_termination | 116,153 | 95,153 | import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PATH_TO_KEYFILE,
GCP_PROJECT_ID,
GCP_REGION,
KUBE_NAMESPACE,
ClusterType,
)
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.data_... | import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PATH_TO_KEYFILE,
GCP_PROJECT_ID,
GCP_REGION,
KUBE_NAMESPACE,
ClusterType,
)
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.data_... | if cluster_type == ClusterType.K8S:
workspaces = get_workspaces(cluster_type)
for ws in workspaces:
try:
termination_policy = ws.lifecycle_config.termination_policy
if termination_policy and termination_policy.enable_auto_termination:
w... | """
Check and potentially terminate idle workspaces in a given cluster. Currently,
this is only supported for Kubernetes clusters.
This function is responsible for checking and, if necessary, terminating idle workspaces
in a specified cluster.
1. Retrieve a list of workspaces based on the clus... | 84 | 1,364 | 455 | 1,819 | import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PATH_TO_KEYFILE,
GCP_PROJECT_ID,
GCP_REGION,
KUBE_NAMESPACE,
ClusterType,
)
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.data_... | import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cluster_manager.constants import (
ECS_CLUSTER_NAME,
GCP_PATH_TO_KEYFILE,
GCP_PROJECT_ID,
GCP_REGION,
KUBE_NAMESPACE,
ClusterType,
)
from mage_ai.cluster_manager.workspace.base import Workspace
from mage_ai.data_... | |
20,526 | /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/command_center/applications/utils.py | 95,96 | 1,135 | build_application_portal_terminal | 96,126 | 96,126 | from typing import Dict
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.presenters.text import application_title
from mage_ai.command_center.shared.utils import (
build_action_fetch_it... | from typing import Dict
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.presenters.text import application_title
from mage_ai.command_center.shared.utils import (
build_action_fetch_it... | return build_generic(model_class=File, item_dict=dict(
item_type=ItemType.DETAIL,
object_type=ObjectType.TERMINAL,
title='Portal Terminal',
description='execute shell commands in a terminal',
subtitle='Terminal',
applications=[
build_application_expansion(... | return build_generic(model_class=File, item_dict=dict(
item_type=ItemType.DETAIL,
object_type=ObjectType.TERMINAL,
title='Portal Terminal',
description='execute shell commands in a terminal',
subtitle='Terminal',
applications=[
build_application_expansion(... | 36 | 854 | 277 | 1,131 | from typing import Dict
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.presenters.text import application_title
from mage_ai.command_center.shared.utils import (
build_action_fetch_it... | from typing import Dict
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.presenters.text import application_title
from mage_ai.command_center.shared.utils import (
build_action_fetch_it... | |
20,527 | /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/command_center/blocks/factory.py | 12,13 | 11,40 | fetch_items | BlockFactory | 13,40 | 13,40 | class BlockFactory(BaseFactory):
async def fetch_items(self, **kwargs) -> List[Dict]:
FILL_FUNC_BODY | class BlockFactory(BaseFactory):
async def fetch_items(self, **kwargs) -> List[Dict]:
FILL_FUNC_BODY | items = []
if self.search:
now = datetime.utcnow().timestamp()
cache = await BlockCache.initialize_cache()
mapping = cache.get(cache.cache_key)
print(f'[BlockFactory] Load: {len(mapping)} - {datetime.utcnow().timestamp() - now}')
data_array =... | items = []
if self.search:
now = datetime.utcnow().timestamp()
cache = await BlockCache.initialize_cache()
mapping = cache.get(cache.cache_key)
print(f'[BlockFactory] Load: {len(mapping)} - {datetime.utcnow().timestamp() - now}')
data_array =... | 74 | 38 | 306 | 344 | import asyncio
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.block import BlockCache
from mage_ai.command_center.blocks.utils import add_application_actions, build_and_score
from mage_ai.command_center.factory import BaseFactory
from mage_ai.shared.hash import merge_dict
class BlockF... | import asyncio
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.block import BlockCache
from mage_ai.command_center.blocks.utils import add_application_actions, build_and_score
from mage_ai.command_center.factory import BaseFactory
from mage_ai.shared.hash import merge_dict
class BlockF... |
20,528 | /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/command_center/blocks/utils.py | 15,16 | 1,128 | add_application_actions | 16,65 | 16,65 | import urllib.parse
from pathlib import Path
from typing import Dict, List, Tuple
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.utils import shorten_directo... | import urllib.parse
from pathlib import Path
from typing import Dict, List, Tuple
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.utils import shorten_directo... | uuid = item_dict.get('uuid')
block_metadata = (item_dict.get('metadata') or {}).get('block') or {}
file_path = block_metadata.get('file_path')
actions = []
buttons = []
pipelines = block_metadata.get('pipelines')
if pipelines:
pipeline_uuid = pipelines[0].get('uuid')
actions... | uuid = item_dict.get('uuid')
block_metadata = (item_dict.get('metadata') or {}).get('block') or {}
file_path = block_metadata.get('file_path')
actions = []
buttons = []
pipelines = block_metadata.get('pipelines')
if pipelines:
pipeline_uuid = pipelines[0].get('uuid')
actions... | 72 | 652 | 430 | 1,082 | import urllib.parse
from pathlib import Path
from typing import Dict, List, Tuple
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.utils import shorten_directo... | import urllib.parse
from pathlib import Path
from typing import Dict, List, Tuple
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
ItemType,
ObjectType,
)
from mage_ai.command_center.utils import shorten_directo... | |
20,529 | /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/command_center/files/constants.py | 196,197 | 1,236 | add_application_actions | 197,236 | 197,236 | import urllib.parse
from typing import Dict
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.policies.FilePolicy import FilePolicy
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.prese... | import urllib.parse
from typing import Dict
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.policies.FilePolicy import FilePolicy
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.prese... | uuid = item_dict.get('uuid')
return dict(
applications=[
dict(
application_type=ApplicationType.DETAIL,
actions=[
dict(
request=dict(
operation=OperationType.DETAIL,
... | uuid = item_dict.get('uuid')
return dict(
applications=[
dict(
application_type=ApplicationType.DETAIL,
actions=[
dict(
request=dict(
operation=OperationType.DETAIL,
... | 42 | 1,500 | 300 | 1,800 | import urllib.parse
from typing import Dict
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.policies.FilePolicy import FilePolicy
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.prese... | import urllib.parse
from typing import Dict
from mage_ai.api.operations.constants import OperationType
from mage_ai.api.policies.FilePolicy import FilePolicy
from mage_ai.command_center.constants import (
ApplicationType,
ButtonActionType,
InteractionType,
ItemType,
ObjectType,
)
from mage_ai.prese... | |
20,530 | /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/command_center/files/factory.py | 25,26 | 14,87 | build_and_score | FileFactory | 26,63 | 26,63 | class FileFactory(BaseFactory):
async def fetch_items(self, **kwargs) -> List[Dict]:
items = []
for item_dict in ITEMS:
item_scored = self.filter_score(item_dict)
if item_scored:
items.append(item_dict)
files = []
async def build_and_score(l... | class FileFactory(BaseFactory):
async def fetch_items(self, **kwargs) -> List[Dict]:
items = []
for item_dict in ITEMS:
item_scored = self.filter_score(item_dict)
if item_scored:
items.append(item_dict)
files = []
async def build_and_score(l... | full_path, file_size, modified_timestamp = line.split(',')
filename = os.path.basename(full_path)
modified_at = datetime.fromtimestamp(float(modified_timestamp)).isoformat()
path_dict = shorten_directory(full_path)
extension = path_dict.get('extension')
... | full_path, file_size, modified_timestamp = line.split(',')
filename = os.path.basename(full_path)
modified_at = datetime.fromtimestamp(float(modified_timestamp)).isoformat()
path_dict = shorten_directory(full_path)
extension = path_dict.get('extension')
... | 52 | 387 | 333 | 720 | import asyncio
import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.file import FileCache
from mage_ai.command_center.constants import ItemType, ObjectType
from mage_ai.command_center.factory import BaseFactory
from mage_ai.command_center.files.constants import ITEMS, add_applicatio... | import asyncio
import os
from datetime import datetime
from typing import Dict, List
from mage_ai.cache.file import FileCache
from mage_ai.command_center.constants import ItemType, ObjectType
from mage_ai.command_center.factory import BaseFactory
from mage_ai.command_center.files.constants import ITEMS, add_applicatio... |
20,531 | /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/command_center/models.py | 396,397 | 370,412 | to_dict | Application | 397,412 | 397,412 | @dataclass
class Application(CommandCenterBaseClass):
application_type: ApplicationType
uuid: str
actions: List[Action] = None
buttons: List[Button] = None
configurations: ApplicationConfigurations = None
expansion_settings: ExpansionSettings = None
settings: List[Union[FormInput, Dict]] = N... | @dataclass
class Application(CommandCenterBaseClass):
application_type: ApplicationType
uuid: str
actions: List[Action] = None
buttons: List[Button] = None
configurations: ApplicationConfigurations = None
expansion_settings: ExpansionSettings = None
settings: List[Union[FormInput, Dict]] = N... | arr = []
if isinstance(self.settings, list):
for value in self.settings:
if isinstance(value, dict):
arr.append(value)
else:
arr.append(value.to_dict(**kwargs))
return merge_dict(
super().to_dict(**... | arr = []
if isinstance(self.settings, list):
for value in self.settings:
if isinstance(value, dict):
arr.append(value)
else:
arr.append(value.to_dict(**kwargs))
return merge_dict(
super().to_dict(**... | 21 | 287 | 111 | 398 | from dataclasses import dataclass, field
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
ButtonActionType,
InteractionType,
ItemTagEnum,
ItemType,
ModeTy... | from dataclasses import dataclass, field
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
ButtonActionType,
InteractionType,
ItemTagEnum,
ItemType,
ModeTy... |
20,532 | /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/command_center/models.py | 42,43 | 40,46 | to_dict | CommandCenterBaseClass | 43,46 | 43,46 | @dataclass
class CommandCenterBaseClass(BaseDataClass):
def to_dict(self, ignore_empty: bool = True, **kwargs) -> Dict:
FILL_FUNC_BODY | @dataclass
class CommandCenterBaseClass(BaseDataClass):
def to_dict(self, ignore_empty: bool = True, **kwargs) -> Dict:
FILL_FUNC_BODY | return super().to_dict(ignore_empty=True, **kwargs)
| return super().to_dict(ignore_empty=True, **kwargs)
| 3 | 51 | 23 | 74 | from dataclasses import dataclass, field
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
ButtonActionType,
InteractionType,
ItemTagEnum,
ItemType,
ModeTy... | from dataclasses import dataclass, field
from typing import Dict, List, Union
from mage_ai.api.operations.constants import OperationType
from mage_ai.command_center.constants import (
ApplicationExpansionUUID,
ApplicationType,
ButtonActionType,
InteractionType,
ItemTagEnum,
ItemType,
ModeTy... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.