mage-ai 0.9.66__py3-none-any.whl → 0.9.67__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mage-ai might be problematic. Click here for more details.
- mage_ai/data_preparation/decorators.py +15 -0
- mage_ai/data_preparation/executors/streaming_pipeline_executor.py +22 -12
- mage_ai/data_preparation/git/api.py +3 -0
- mage_ai/data_preparation/git/clients/gitlab.py +3 -2
- mage_ai/data_preparation/models/block/__init__.py +24 -18
- mage_ai/data_preparation/storage/gcs_storage.py +27 -2
- mage_ai/data_preparation/storage/local_storage.py +18 -3
- mage_ai/data_preparation/storage/s3_storage.py +7 -2
- mage_ai/data_preparation/templates/data_loaders/streaming/generic_python.py +23 -0
- mage_ai/data_preparation/templates/template.py +6 -2
- mage_ai/data_preparation/variable_manager.py +2 -1
- mage_ai/io/bigquery.py +2 -0
- mage_ai/io/oracledb.py +14 -2
- mage_ai/orchestration/job_manager.py +6 -1
- mage_ai/server/constants.py +1 -1
- mage_ai/server/frontend_dist/404.html +2 -2
- mage_ai/server/frontend_dist/_next/static/chunks/pages/{_app-913116aa749f7ca6.js → _app-1c1ffd928f5a00f7.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/index-b7b8695a7f9efde2.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/{edit-d84556cefbe31a1a.js → edit-36377e679da2cd91.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-3f5c14076ddde20e.js +1 -0
- mage_ai/server/frontend_dist/_next/static/{rtugsJoijF2SsCCB5_yKS → vPsMu6Fi2zrHaf2fRXKRO}/_buildManifest.js +1 -1
- mage_ai/server/frontend_dist/block-layout.html +2 -2
- mage_ai/server/frontend_dist/compute.html +2 -2
- mage_ai/server/frontend_dist/files.html +2 -2
- mage_ai/server/frontend_dist/global-data-products/[...slug].html +2 -2
- mage_ai/server/frontend_dist/global-data-products.html +2 -2
- mage_ai/server/frontend_dist/global-hooks/[...slug].html +2 -2
- mage_ai/server/frontend_dist/global-hooks.html +2 -2
- mage_ai/server/frontend_dist/index.html +2 -2
- mage_ai/server/frontend_dist/manage/files.html +2 -2
- mage_ai/server/frontend_dist/manage/settings.html +2 -2
- mage_ai/server/frontend_dist/manage/users/[user].html +2 -2
- mage_ai/server/frontend_dist/manage/users/new.html +2 -2
- mage_ai/server/frontend_dist/manage/users.html +2 -2
- mage_ai/server/frontend_dist/manage.html +2 -2
- mage_ai/server/frontend_dist/oauth.html +2 -2
- mage_ai/server/frontend_dist/overview.html +2 -2
- mage_ai/server/frontend_dist/pipeline-runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills/[...slug].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/dashboard.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/edit.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/logs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/runs/[run].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/settings.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/syncs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers/[...slug].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline].html +2 -2
- mage_ai/server/frontend_dist/pipelines.html +2 -2
- mage_ai/server/frontend_dist/platform/global-hooks/[...slug].html +2 -2
- mage_ai/server/frontend_dist/platform/global-hooks.html +2 -2
- mage_ai/server/frontend_dist/settings/account/profile.html +2 -2
- mage_ai/server/frontend_dist/settings/platform/preferences.html +2 -2
- mage_ai/server/frontend_dist/settings/platform/settings.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/permissions/[...slug].html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/permissions.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/preferences.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/roles/[...slug].html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/roles.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/sync-data.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/users/[...slug].html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/users.html +2 -2
- mage_ai/server/frontend_dist/settings.html +2 -2
- mage_ai/server/frontend_dist/sign-in.html +2 -2
- mage_ai/server/frontend_dist/templates/[...slug].html +2 -2
- mage_ai/server/frontend_dist/templates.html +2 -2
- mage_ai/server/frontend_dist/terminal.html +2 -2
- mage_ai/server/frontend_dist/test.html +2 -2
- mage_ai/server/frontend_dist/triggers.html +2 -2
- mage_ai/server/frontend_dist/version-control.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/404.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/{_app-913116aa749f7ca6.js → _app-1c1ffd928f5a00f7.js} +1 -1
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/index-b7b8695a7f9efde2.js +1 -0
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/{edit-d84556cefbe31a1a.js → edit-36377e679da2cd91.js} +1 -1
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/logs-3f5c14076ddde20e.js +1 -0
- mage_ai/server/frontend_dist_base_path_template/_next/static/{wxqkF4diPqRxUfP6Ac6ai → khKiaJtwrslgMmp4YSa1f}/_buildManifest.js +1 -1
- mage_ai/server/frontend_dist_base_path_template/block-layout.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/compute.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/files.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/global-data-products/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/global-data-products.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/global-hooks/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/global-hooks.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/index.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage/files.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage/settings.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage/users/[user].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage/users/new.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage/users.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/manage.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/oauth.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/overview.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipeline-runs.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/backfills/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/backfills.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/dashboard.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/edit.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/logs.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors/block-runs.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/runs/[run].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/runs.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/settings.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/syncs.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/triggers/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/triggers.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/pipelines.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/platform/global-hooks/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/platform/global-hooks.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/account/profile.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/platform/preferences.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/platform/settings.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/permissions/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/permissions.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/preferences.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/roles/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/roles.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/sync-data.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/users/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings/workspace/users.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/settings.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/sign-in.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/templates/[...slug].html +2 -2
- mage_ai/server/frontend_dist_base_path_template/templates.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/terminal.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/test.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/triggers.html +2 -2
- mage_ai/server/frontend_dist_base_path_template/version-control.html +2 -2
- mage_ai/services/aws/s3/s3.py +8 -2
- mage_ai/settings/server.py +6 -1
- mage_ai/shared/logger.py +12 -6
- mage_ai/streaming/sources/base_python.py +30 -0
- mage_ai/streaming/sources/source_factory.py +25 -0
- mage_ai/tests/data_preparation/models/test_block.py +39 -2
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/METADATA +1 -1
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/RECORD +149 -147
- mage_ai/server/frontend_dist/_next/static/chunks/pages/index-64851458dde54ad9.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-cf656cbe37ecaacc.js +0 -1
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/index-64851458dde54ad9.js +0 -1
- mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/logs-cf656cbe37ecaacc.js +0 -1
- /mage_ai/server/frontend_dist/_next/static/{rtugsJoijF2SsCCB5_yKS → vPsMu6Fi2zrHaf2fRXKRO}/_ssgManifest.js +0 -0
- /mage_ai/server/frontend_dist_base_path_template/_next/static/{wxqkF4diPqRxUfP6Ac6ai → khKiaJtwrslgMmp4YSa1f}/_ssgManifest.js +0 -0
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/LICENSE +0 -0
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/WHEEL +0 -0
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/entry_points.txt +0 -0
- {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/top_level.txt +0 -0
mage_ai/shared/logger.py
CHANGED
|
@@ -5,6 +5,7 @@ from contextlib import contextmanager, redirect_stdout
|
|
|
5
5
|
from enum import Enum
|
|
6
6
|
from typing import Callable, List
|
|
7
7
|
|
|
8
|
+
from mage_ai.settings import SERVER_LOGGING_TEMPLATE
|
|
8
9
|
from mage_ai.shared.hash import merge_dict
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger(__name__)
|
|
@@ -84,16 +85,21 @@ class JSONFormatter(logging.Formatter):
|
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
def set_logging_format(logging_format: str = None, level: str = None) -> None:
|
|
87
|
-
handler = logging.StreamHandler()
|
|
88
|
-
handler.setFormatter(JSONFormatter())
|
|
89
|
-
|
|
90
|
-
root_logger = logging.getLogger()
|
|
91
88
|
if isinstance(logging_format, str):
|
|
92
89
|
logging_format = logging_format.lower()
|
|
90
|
+
|
|
91
|
+
root_logger = logging.getLogger()
|
|
92
|
+
if len(root_logger.handlers) > 0:
|
|
93
|
+
root_logger.removeHandler(root_logger.handlers[0])
|
|
94
|
+
|
|
95
|
+
handler = logging.StreamHandler()
|
|
93
96
|
if logging_format == 'json':
|
|
94
|
-
|
|
95
|
-
root_logger.removeHandler(root_logger.handlers[0])
|
|
97
|
+
handler.setFormatter(JSONFormatter())
|
|
96
98
|
root_logger.addHandler(handler)
|
|
99
|
+
else:
|
|
100
|
+
handler.setFormatter(logging.Formatter(SERVER_LOGGING_TEMPLATE))
|
|
101
|
+
root_logger.addHandler(handler)
|
|
102
|
+
|
|
97
103
|
if level:
|
|
98
104
|
try:
|
|
99
105
|
root_logger.setLevel(level.upper())
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from mage_ai.streaming.sources.base import BaseSource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BasePythonSource(BaseSource):
|
|
7
|
+
def __init__(self, **kwargs):
|
|
8
|
+
"""
|
|
9
|
+
Not require config in the python source
|
|
10
|
+
"""
|
|
11
|
+
super().__init__(None, **kwargs)
|
|
12
|
+
|
|
13
|
+
def init_client(self):
|
|
14
|
+
"""
|
|
15
|
+
Intialize the client for the source.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def read(self, handler: Callable):
|
|
19
|
+
"""
|
|
20
|
+
Read the message from the source and use handler to process the message.
|
|
21
|
+
|
|
22
|
+
This method only needs to be implemented when consume_method is 'READ'.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def batch_read(self, handler: Callable):
|
|
26
|
+
"""
|
|
27
|
+
Batch read the messages from the source and use handler to process the messages.
|
|
28
|
+
|
|
29
|
+
This method only needs to be implemented when consume_method is 'BATCH_READ'.
|
|
30
|
+
"""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import Dict
|
|
2
2
|
|
|
3
|
+
from mage_ai.data_preparation.decorators import collect_decorated_objs
|
|
3
4
|
from mage_ai.streaming.constants import SourceType
|
|
4
5
|
|
|
5
6
|
|
|
@@ -51,3 +52,27 @@ class SourceFactory:
|
|
|
51
52
|
raise Exception(
|
|
52
53
|
f'Consuming data from {connector_type} is not supported in streaming pipelines yet.',
|
|
53
54
|
)
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def get_python_source(self, content: str, **kwargs):
|
|
58
|
+
"""
|
|
59
|
+
Find the class that's decorated with streaming_source from the source code.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
content (str): The python code that contains the streaming source implementation.
|
|
63
|
+
**kwargs: {'global_vars': {...}}
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
The initialized class object.
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
Exception: Description
|
|
70
|
+
"""
|
|
71
|
+
decorated_sources = []
|
|
72
|
+
|
|
73
|
+
exec(content, {'streaming_source': collect_decorated_objs(decorated_sources)})
|
|
74
|
+
|
|
75
|
+
if not decorated_sources:
|
|
76
|
+
raise Exception('Not find the class that has streaming_source decorator.')
|
|
77
|
+
|
|
78
|
+
return decorated_sources[0](**kwargs)
|
|
@@ -7,14 +7,17 @@ from faker import Faker
|
|
|
7
7
|
from pandas.testing import assert_frame_equal
|
|
8
8
|
|
|
9
9
|
# from mage_ai.data_cleaner.column_types.constants import ColumnType
|
|
10
|
-
from mage_ai.data_preparation.models.block import Block, BlockType
|
|
10
|
+
from mage_ai.data_preparation.models.block import Block, BlockType, CallbackBlock
|
|
11
11
|
from mage_ai.data_preparation.models.block.errors import HasDownstreamDependencies
|
|
12
12
|
from mage_ai.data_preparation.models.pipeline import Pipeline
|
|
13
13
|
from mage_ai.data_preparation.repo_manager import get_repo_config
|
|
14
14
|
from mage_ai.data_preparation.variable_manager import VariableManager
|
|
15
15
|
from mage_ai.shared.path_fixer import add_root_repo_path_to_relative_path
|
|
16
16
|
from mage_ai.tests.base_test import DBTestCase
|
|
17
|
-
from mage_ai.tests.factory import
|
|
17
|
+
from mage_ai.tests.factory import (
|
|
18
|
+
create_integration_pipeline_with_blocks,
|
|
19
|
+
create_pipeline,
|
|
20
|
+
)
|
|
18
21
|
from mage_ai.tests.shared.mixins import ProjectPlatformMixin
|
|
19
22
|
|
|
20
23
|
|
|
@@ -763,3 +766,37 @@ class BlockProjectPlatformTests(ProjectPlatformMixin):
|
|
|
763
766
|
)
|
|
764
767
|
|
|
765
768
|
self.assertEqual(block.file_path, add_root_repo_path_to_relative_path(path))
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
class CallbackBlockTest(DBTestCase):
|
|
772
|
+
def setUp(self):
|
|
773
|
+
self.pipeline = create_pipeline('callback_pipeline', self.repo_path)
|
|
774
|
+
|
|
775
|
+
def tearDown(self):
|
|
776
|
+
self.pipeline.delete()
|
|
777
|
+
|
|
778
|
+
def test_create_global_vars_from_parent_block(self):
|
|
779
|
+
parent_block = Block.create(
|
|
780
|
+
'test_data_loader',
|
|
781
|
+
'data_loader',
|
|
782
|
+
self.repo_path,
|
|
783
|
+
pipeline=self.pipeline,
|
|
784
|
+
)
|
|
785
|
+
callback_block = CallbackBlock.create(parent_block.name)
|
|
786
|
+
self.pipeline.add_block(callback_block)
|
|
787
|
+
parent_block = parent_block.update(
|
|
788
|
+
dict(callback_blocks=[callback_block.uuid])
|
|
789
|
+
)
|
|
790
|
+
parent_block.global_vars = dict(
|
|
791
|
+
configuration=dict(table_name='load_data_table')
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
global_vars = dict(
|
|
795
|
+
random_var=1,
|
|
796
|
+
)
|
|
797
|
+
new_vars = callback_block._create_global_vars(
|
|
798
|
+
global_vars,
|
|
799
|
+
parent_block=parent_block,
|
|
800
|
+
)
|
|
801
|
+
|
|
802
|
+
self.assertIsNotNone(new_vars.get('configuration'))
|