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.

Files changed (153) hide show
  1. mage_ai/data_preparation/decorators.py +15 -0
  2. mage_ai/data_preparation/executors/streaming_pipeline_executor.py +22 -12
  3. mage_ai/data_preparation/git/api.py +3 -0
  4. mage_ai/data_preparation/git/clients/gitlab.py +3 -2
  5. mage_ai/data_preparation/models/block/__init__.py +24 -18
  6. mage_ai/data_preparation/storage/gcs_storage.py +27 -2
  7. mage_ai/data_preparation/storage/local_storage.py +18 -3
  8. mage_ai/data_preparation/storage/s3_storage.py +7 -2
  9. mage_ai/data_preparation/templates/data_loaders/streaming/generic_python.py +23 -0
  10. mage_ai/data_preparation/templates/template.py +6 -2
  11. mage_ai/data_preparation/variable_manager.py +2 -1
  12. mage_ai/io/bigquery.py +2 -0
  13. mage_ai/io/oracledb.py +14 -2
  14. mage_ai/orchestration/job_manager.py +6 -1
  15. mage_ai/server/constants.py +1 -1
  16. mage_ai/server/frontend_dist/404.html +2 -2
  17. mage_ai/server/frontend_dist/_next/static/chunks/pages/{_app-913116aa749f7ca6.js → _app-1c1ffd928f5a00f7.js} +1 -1
  18. mage_ai/server/frontend_dist/_next/static/chunks/pages/index-b7b8695a7f9efde2.js +1 -0
  19. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/{edit-d84556cefbe31a1a.js → edit-36377e679da2cd91.js} +1 -1
  20. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-3f5c14076ddde20e.js +1 -0
  21. mage_ai/server/frontend_dist/_next/static/{rtugsJoijF2SsCCB5_yKS → vPsMu6Fi2zrHaf2fRXKRO}/_buildManifest.js +1 -1
  22. mage_ai/server/frontend_dist/block-layout.html +2 -2
  23. mage_ai/server/frontend_dist/compute.html +2 -2
  24. mage_ai/server/frontend_dist/files.html +2 -2
  25. mage_ai/server/frontend_dist/global-data-products/[...slug].html +2 -2
  26. mage_ai/server/frontend_dist/global-data-products.html +2 -2
  27. mage_ai/server/frontend_dist/global-hooks/[...slug].html +2 -2
  28. mage_ai/server/frontend_dist/global-hooks.html +2 -2
  29. mage_ai/server/frontend_dist/index.html +2 -2
  30. mage_ai/server/frontend_dist/manage/files.html +2 -2
  31. mage_ai/server/frontend_dist/manage/settings.html +2 -2
  32. mage_ai/server/frontend_dist/manage/users/[user].html +2 -2
  33. mage_ai/server/frontend_dist/manage/users/new.html +2 -2
  34. mage_ai/server/frontend_dist/manage/users.html +2 -2
  35. mage_ai/server/frontend_dist/manage.html +2 -2
  36. mage_ai/server/frontend_dist/oauth.html +2 -2
  37. mage_ai/server/frontend_dist/overview.html +2 -2
  38. mage_ai/server/frontend_dist/pipeline-runs.html +2 -2
  39. mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills/[...slug].html +2 -2
  40. mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills.html +2 -2
  41. mage_ai/server/frontend_dist/pipelines/[pipeline]/dashboard.html +2 -2
  42. mage_ai/server/frontend_dist/pipelines/[pipeline]/edit.html +2 -2
  43. mage_ai/server/frontend_dist/pipelines/[pipeline]/logs.html +2 -2
  44. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runs.html +2 -2
  45. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
  46. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors.html +2 -2
  47. mage_ai/server/frontend_dist/pipelines/[pipeline]/runs/[run].html +2 -2
  48. mage_ai/server/frontend_dist/pipelines/[pipeline]/runs.html +2 -2
  49. mage_ai/server/frontend_dist/pipelines/[pipeline]/settings.html +2 -2
  50. mage_ai/server/frontend_dist/pipelines/[pipeline]/syncs.html +2 -2
  51. mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers/[...slug].html +2 -2
  52. mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers.html +2 -2
  53. mage_ai/server/frontend_dist/pipelines/[pipeline].html +2 -2
  54. mage_ai/server/frontend_dist/pipelines.html +2 -2
  55. mage_ai/server/frontend_dist/platform/global-hooks/[...slug].html +2 -2
  56. mage_ai/server/frontend_dist/platform/global-hooks.html +2 -2
  57. mage_ai/server/frontend_dist/settings/account/profile.html +2 -2
  58. mage_ai/server/frontend_dist/settings/platform/preferences.html +2 -2
  59. mage_ai/server/frontend_dist/settings/platform/settings.html +2 -2
  60. mage_ai/server/frontend_dist/settings/workspace/permissions/[...slug].html +2 -2
  61. mage_ai/server/frontend_dist/settings/workspace/permissions.html +2 -2
  62. mage_ai/server/frontend_dist/settings/workspace/preferences.html +2 -2
  63. mage_ai/server/frontend_dist/settings/workspace/roles/[...slug].html +2 -2
  64. mage_ai/server/frontend_dist/settings/workspace/roles.html +2 -2
  65. mage_ai/server/frontend_dist/settings/workspace/sync-data.html +2 -2
  66. mage_ai/server/frontend_dist/settings/workspace/users/[...slug].html +2 -2
  67. mage_ai/server/frontend_dist/settings/workspace/users.html +2 -2
  68. mage_ai/server/frontend_dist/settings.html +2 -2
  69. mage_ai/server/frontend_dist/sign-in.html +2 -2
  70. mage_ai/server/frontend_dist/templates/[...slug].html +2 -2
  71. mage_ai/server/frontend_dist/templates.html +2 -2
  72. mage_ai/server/frontend_dist/terminal.html +2 -2
  73. mage_ai/server/frontend_dist/test.html +2 -2
  74. mage_ai/server/frontend_dist/triggers.html +2 -2
  75. mage_ai/server/frontend_dist/version-control.html +2 -2
  76. mage_ai/server/frontend_dist_base_path_template/404.html +2 -2
  77. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/{_app-913116aa749f7ca6.js → _app-1c1ffd928f5a00f7.js} +1 -1
  78. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/index-b7b8695a7f9efde2.js +1 -0
  79. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/{edit-d84556cefbe31a1a.js → edit-36377e679da2cd91.js} +1 -1
  80. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/logs-3f5c14076ddde20e.js +1 -0
  81. mage_ai/server/frontend_dist_base_path_template/_next/static/{wxqkF4diPqRxUfP6Ac6ai → khKiaJtwrslgMmp4YSa1f}/_buildManifest.js +1 -1
  82. mage_ai/server/frontend_dist_base_path_template/block-layout.html +2 -2
  83. mage_ai/server/frontend_dist_base_path_template/compute.html +2 -2
  84. mage_ai/server/frontend_dist_base_path_template/files.html +2 -2
  85. mage_ai/server/frontend_dist_base_path_template/global-data-products/[...slug].html +2 -2
  86. mage_ai/server/frontend_dist_base_path_template/global-data-products.html +2 -2
  87. mage_ai/server/frontend_dist_base_path_template/global-hooks/[...slug].html +2 -2
  88. mage_ai/server/frontend_dist_base_path_template/global-hooks.html +2 -2
  89. mage_ai/server/frontend_dist_base_path_template/index.html +2 -2
  90. mage_ai/server/frontend_dist_base_path_template/manage/files.html +2 -2
  91. mage_ai/server/frontend_dist_base_path_template/manage/settings.html +2 -2
  92. mage_ai/server/frontend_dist_base_path_template/manage/users/[user].html +2 -2
  93. mage_ai/server/frontend_dist_base_path_template/manage/users/new.html +2 -2
  94. mage_ai/server/frontend_dist_base_path_template/manage/users.html +2 -2
  95. mage_ai/server/frontend_dist_base_path_template/manage.html +2 -2
  96. mage_ai/server/frontend_dist_base_path_template/oauth.html +2 -2
  97. mage_ai/server/frontend_dist_base_path_template/overview.html +2 -2
  98. mage_ai/server/frontend_dist_base_path_template/pipeline-runs.html +2 -2
  99. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/backfills/[...slug].html +2 -2
  100. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/backfills.html +2 -2
  101. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/dashboard.html +2 -2
  102. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/edit.html +2 -2
  103. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/logs.html +2 -2
  104. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors/block-runs.html +2 -2
  105. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
  106. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/monitors.html +2 -2
  107. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/runs/[run].html +2 -2
  108. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/runs.html +2 -2
  109. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/settings.html +2 -2
  110. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/syncs.html +2 -2
  111. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/triggers/[...slug].html +2 -2
  112. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline]/triggers.html +2 -2
  113. mage_ai/server/frontend_dist_base_path_template/pipelines/[pipeline].html +2 -2
  114. mage_ai/server/frontend_dist_base_path_template/pipelines.html +2 -2
  115. mage_ai/server/frontend_dist_base_path_template/platform/global-hooks/[...slug].html +2 -2
  116. mage_ai/server/frontend_dist_base_path_template/platform/global-hooks.html +2 -2
  117. mage_ai/server/frontend_dist_base_path_template/settings/account/profile.html +2 -2
  118. mage_ai/server/frontend_dist_base_path_template/settings/platform/preferences.html +2 -2
  119. mage_ai/server/frontend_dist_base_path_template/settings/platform/settings.html +2 -2
  120. mage_ai/server/frontend_dist_base_path_template/settings/workspace/permissions/[...slug].html +2 -2
  121. mage_ai/server/frontend_dist_base_path_template/settings/workspace/permissions.html +2 -2
  122. mage_ai/server/frontend_dist_base_path_template/settings/workspace/preferences.html +2 -2
  123. mage_ai/server/frontend_dist_base_path_template/settings/workspace/roles/[...slug].html +2 -2
  124. mage_ai/server/frontend_dist_base_path_template/settings/workspace/roles.html +2 -2
  125. mage_ai/server/frontend_dist_base_path_template/settings/workspace/sync-data.html +2 -2
  126. mage_ai/server/frontend_dist_base_path_template/settings/workspace/users/[...slug].html +2 -2
  127. mage_ai/server/frontend_dist_base_path_template/settings/workspace/users.html +2 -2
  128. mage_ai/server/frontend_dist_base_path_template/settings.html +2 -2
  129. mage_ai/server/frontend_dist_base_path_template/sign-in.html +2 -2
  130. mage_ai/server/frontend_dist_base_path_template/templates/[...slug].html +2 -2
  131. mage_ai/server/frontend_dist_base_path_template/templates.html +2 -2
  132. mage_ai/server/frontend_dist_base_path_template/terminal.html +2 -2
  133. mage_ai/server/frontend_dist_base_path_template/test.html +2 -2
  134. mage_ai/server/frontend_dist_base_path_template/triggers.html +2 -2
  135. mage_ai/server/frontend_dist_base_path_template/version-control.html +2 -2
  136. mage_ai/services/aws/s3/s3.py +8 -2
  137. mage_ai/settings/server.py +6 -1
  138. mage_ai/shared/logger.py +12 -6
  139. mage_ai/streaming/sources/base_python.py +30 -0
  140. mage_ai/streaming/sources/source_factory.py +25 -0
  141. mage_ai/tests/data_preparation/models/test_block.py +39 -2
  142. {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/METADATA +1 -1
  143. {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/RECORD +149 -147
  144. mage_ai/server/frontend_dist/_next/static/chunks/pages/index-64851458dde54ad9.js +0 -1
  145. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-cf656cbe37ecaacc.js +0 -1
  146. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/index-64851458dde54ad9.js +0 -1
  147. mage_ai/server/frontend_dist_base_path_template/_next/static/chunks/pages/pipelines/[pipeline]/logs-cf656cbe37ecaacc.js +0 -1
  148. /mage_ai/server/frontend_dist/_next/static/{rtugsJoijF2SsCCB5_yKS → vPsMu6Fi2zrHaf2fRXKRO}/_ssgManifest.js +0 -0
  149. /mage_ai/server/frontend_dist_base_path_template/_next/static/{wxqkF4diPqRxUfP6Ac6ai → khKiaJtwrslgMmp4YSa1f}/_ssgManifest.js +0 -0
  150. {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/LICENSE +0 -0
  151. {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/WHEEL +0 -0
  152. {mage_ai-0.9.66.dist-info → mage_ai-0.9.67.dist-info}/entry_points.txt +0 -0
  153. {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
- if len(root_logger.handlers) > 0:
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 create_integration_pipeline_with_blocks
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'))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mage-ai
3
- Version: 0.9.66
3
+ Version: 0.9.67
4
4
  Summary: Mage is a tool for building and deploying data pipelines.
5
5
  Home-page: https://github.com/mage-ai/mage-ai
6
6
  Author: Mage