meerschaum 2.2.5.dev3__py3-none-any.whl → 2.2.7__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.
Files changed (65) hide show
  1. meerschaum/__init__.py +4 -1
  2. meerschaum/__main__.py +10 -5
  3. meerschaum/_internal/arguments/_parser.py +13 -2
  4. meerschaum/_internal/docs/index.py +523 -26
  5. meerschaum/_internal/entry.py +13 -13
  6. meerschaum/_internal/shell/Shell.py +26 -22
  7. meerschaum/_internal/shell/updates.py +175 -0
  8. meerschaum/_internal/term/__init__.py +2 -2
  9. meerschaum/actions/bootstrap.py +13 -14
  10. meerschaum/actions/python.py +11 -8
  11. meerschaum/actions/register.py +149 -37
  12. meerschaum/actions/show.py +79 -71
  13. meerschaum/actions/stop.py +11 -11
  14. meerschaum/actions/sync.py +3 -3
  15. meerschaum/actions/upgrade.py +28 -36
  16. meerschaum/api/dash/callbacks/login.py +21 -13
  17. meerschaum/api/dash/pages/login.py +2 -2
  18. meerschaum/api/routes/_login.py +5 -5
  19. meerschaum/api/routes/_pipes.py +20 -20
  20. meerschaum/config/__init__.py +8 -1
  21. meerschaum/config/_formatting.py +1 -0
  22. meerschaum/config/_paths.py +24 -2
  23. meerschaum/config/_shell.py +78 -66
  24. meerschaum/config/_version.py +1 -1
  25. meerschaum/config/paths.py +21 -2
  26. meerschaum/config/static/__init__.py +2 -0
  27. meerschaum/connectors/Connector.py +7 -2
  28. meerschaum/connectors/__init__.py +7 -5
  29. meerschaum/connectors/api/APIConnector.py +7 -2
  30. meerschaum/connectors/api/_actions.py +23 -31
  31. meerschaum/connectors/api/_misc.py +1 -1
  32. meerschaum/connectors/api/_request.py +13 -9
  33. meerschaum/connectors/api/_uri.py +5 -5
  34. meerschaum/core/Pipe/__init__.py +7 -3
  35. meerschaum/core/Pipe/_data.py +23 -15
  36. meerschaum/core/Pipe/_deduplicate.py +1 -1
  37. meerschaum/core/Pipe/_dtypes.py +5 -0
  38. meerschaum/core/Pipe/_fetch.py +18 -16
  39. meerschaum/core/Pipe/_sync.py +23 -15
  40. meerschaum/plugins/_Plugin.py +6 -6
  41. meerschaum/plugins/__init__.py +1 -1
  42. meerschaum/utils/daemon/Daemon.py +88 -129
  43. meerschaum/utils/daemon/FileDescriptorInterceptor.py +14 -5
  44. meerschaum/utils/daemon/RotatingFile.py +23 -17
  45. meerschaum/utils/daemon/__init__.py +28 -21
  46. meerschaum/utils/dataframe.py +12 -4
  47. meerschaum/utils/debug.py +9 -15
  48. meerschaum/utils/formatting/__init__.py +92 -46
  49. meerschaum/utils/formatting/_jobs.py +47 -9
  50. meerschaum/utils/misc.py +117 -11
  51. meerschaum/utils/packages/__init__.py +28 -16
  52. meerschaum/utils/prompt.py +5 -0
  53. meerschaum/utils/schedule.py +21 -15
  54. meerschaum/utils/typing.py +1 -0
  55. meerschaum/utils/venv/__init__.py +5 -1
  56. meerschaum/utils/warnings.py +8 -1
  57. meerschaum/utils/yaml.py +2 -2
  58. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/METADATA +1 -1
  59. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/RECORD +65 -64
  60. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/WHEEL +1 -1
  61. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/LICENSE +0 -0
  62. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/NOTICE +0 -0
  63. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/entry_points.txt +0 -0
  64. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/top_level.txt +0 -0
  65. {meerschaum-2.2.5.dev3.dist-info → meerschaum-2.2.7.dist-info}/zip-safe +0 -0
@@ -34,12 +34,29 @@ if ENVIRONMENT_ROOT_DIR in os.environ:
34
34
  f"Invalid root directory '{str(_ROOT_DIR_PATH)}' set for " +
35
35
  f"environment variable '{ENVIRONMENT_ROOT_DIR}'.\n" +
36
36
  f"Please enter a valid path for {ENVIRONMENT_ROOT_DIR}.",
37
- file = sys.stderr,
37
+ file=sys.stderr,
38
38
  )
39
39
  sys.exit(1)
40
40
  else:
41
41
  _ROOT_DIR_PATH = DEFAULT_ROOT_DIR_PATH
42
42
 
43
+
44
+ ENVIRONMENT_CONFIG_DIR = STATIC_CONFIG['environment']['config_dir']
45
+ if ENVIRONMENT_CONFIG_DIR in os.environ:
46
+ _CONFIG_DIR_PATH = Path(os.environ[ENVIRONMENT_CONFIG_DIR]).resolve()
47
+ if not _CONFIG_DIR_PATH.exists():
48
+ print(
49
+ (
50
+ f"Invalid configuration directory '{_CONFIG_DIR_PATH}' set"
51
+ + f" for environment variable '{ENVIRONMENT_CONFIG_DIR}'\n"
52
+ + f"Please enter a valid path for {ENVIRONMENT_CONFIG_DIR}."
53
+ ),
54
+ file=sys.stderr,
55
+ )
56
+ sys.exit(1)
57
+ else:
58
+ _CONFIG_DIR_PATH = _ROOT_DIR_PATH / 'config'
59
+
43
60
  ENVIRONMENT_PLUGINS_DIR = STATIC_CONFIG['environment']['plugins']
44
61
  if ENVIRONMENT_PLUGINS_DIR in os.environ:
45
62
  try:
@@ -100,12 +117,16 @@ paths = {
100
117
  'PACKAGE_ROOT_PATH' : Path(__file__).parent.parent.resolve().as_posix(),
101
118
  'ROOT_DIR_PATH' : _ROOT_DIR_PATH.as_posix(),
102
119
  'VIRTENV_RESOURCES_PATH' : _VENVS_DIR_PATH.as_posix(),
103
- 'CONFIG_DIR_PATH' : ('{ROOT_DIR_PATH}', 'config'),
120
+ 'CONFIG_DIR_PATH' : _CONFIG_DIR_PATH.as_posix(),
104
121
  'DEFAULT_CONFIG_DIR_PATH' : ('{ROOT_DIR_PATH}', 'default_config'),
105
122
  'PATCH_DIR_PATH' : ('{ROOT_DIR_PATH}', 'patch_config'),
106
123
  'PERMANENT_PATCH_DIR_PATH' : ('{ROOT_DIR_PATH}', 'permanent_patch_config'),
107
124
  'INTERNAL_RESOURCES_PATH' : ('{ROOT_DIR_PATH}', '.internal'),
108
125
 
126
+ 'UPDATES_RESOURCES_PATH' : ('{INTERNAL_RESOURCES_PATH}', 'updates'),
127
+ 'UPDATES_CACHE_PATH' : ('{UPDATES_RESOURCES_PATH}', 'cache.json'),
128
+ 'UPDATES_LOCK_PATH' : ('{UPDATES_RESOURCES_PATH}', '.updates.lock'),
129
+
109
130
  'STACK_RESOURCES_PATH' : ('{ROOT_DIR_PATH}', 'stack'),
110
131
  'STACK_COMPOSE_FILENAME' : 'docker-compose.yaml',
111
132
  'STACK_COMPOSE_PATH' : ('{STACK_RESOURCES_PATH}', '{STACK_COMPOSE_FILENAME}'),
@@ -168,6 +189,7 @@ def set_root(root: Union[Path, str]):
168
189
  if isinstance(path_parts, tuple) and path_parts[0] == '{ROOT_DIR_PATH}':
169
190
  globals()[path_name] = __getattr__(path_name)
170
191
 
192
+
171
193
  def __getattr__(name: str) -> Path:
172
194
  if name not in paths:
173
195
  if name not in globals():
@@ -6,127 +6,139 @@
6
6
  Default configuration for the Meerschaum shell.
7
7
  """
8
8
 
9
- # import platform
10
- # default_cmd = 'cmd' if platform.system() != 'Windows' else 'cmd2'
11
9
  default_cmd = 'cmd'
12
10
 
13
11
  default_shell_config = {
14
- 'ansi' : {
15
- 'intro' : {
16
- 'rich' : {
17
- 'style' : "bold bright_blue",
12
+ 'ansi' : {
13
+ 'intro' : {
14
+ 'rich' : {
15
+ 'style' : "bold bright_blue",
18
16
  },
19
- 'color' : [
17
+ 'color' : [
20
18
  'bold',
21
19
  'bright blue',
22
20
  ],
23
21
  },
24
- 'close_message': {
25
- 'rich' : {
26
- 'style' : 'bright_blue',
22
+ 'close_message' : {
23
+ 'rich' : {
24
+ 'style' : 'bright_blue',
27
25
  },
28
- 'color' : [
26
+ 'color' : [
29
27
  'bright blue',
30
28
  ],
31
29
  },
32
- 'doc_header': {
33
- 'rich' : {
34
- 'style' : 'bright_blue',
30
+ 'doc_header' : {
31
+ 'rich' : {
32
+ 'style' : 'bright_blue',
35
33
  },
36
- 'color' : [
34
+ 'color' : [
37
35
  'bright blue',
38
36
  ],
39
37
  },
40
- 'undoc_header': {
41
- 'rich' : {
42
- 'style' : 'bright_blue',
38
+ 'undoc_header' : {
39
+ 'rich' : {
40
+ 'style' : 'bright_blue',
43
41
  },
44
- 'color' : [
42
+ 'color' : [
45
43
  'bright blue',
46
44
  ],
47
45
  },
48
- 'ruler': {
49
- 'rich' : {
50
- 'style' : 'bold bright_blue',
46
+ 'ruler' : {
47
+ 'rich' : {
48
+ 'style' : 'bold bright_blue',
51
49
  },
52
- 'color' : [
50
+ 'color' : [
53
51
  'bold',
54
52
  'bright blue',
55
53
  ],
56
54
  },
57
- 'prompt': {
58
- 'rich' : {
59
- 'style' : 'green',
55
+ 'prompt' : {
56
+ 'rich' : {
57
+ 'style' : 'green',
60
58
  },
61
- 'color' : [
59
+ 'color' : [
62
60
  'green',
63
61
  ],
64
62
  },
65
- 'instance' : {
66
- 'rich' : {
67
- 'style' : 'cyan',
63
+ 'instance' : {
64
+ 'rich' : {
65
+ 'style' : 'cyan',
68
66
  },
69
- 'color' : [
67
+ 'color' : [
70
68
  'cyan',
71
69
  ],
72
70
  },
73
- 'repo' : {
74
- 'rich': {
75
- 'style': 'magenta',
71
+ 'repo' : {
72
+ 'rich' : {
73
+ 'style' : 'magenta',
76
74
  },
77
- 'color': [
75
+ 'color' : [
78
76
  'magenta',
79
77
  ],
80
78
  },
81
- 'username' : {
82
- 'rich' : {
83
- 'style' : 'white',
79
+ 'username' : {
80
+ 'rich' : {
81
+ 'style' : 'white',
84
82
  },
85
- 'color' : [
83
+ 'color' : [
86
84
  'white',
87
85
  ],
88
86
  },
89
- 'connected' : {
90
- 'rich' : {
91
- 'style' : 'green',
87
+ 'connected' : {
88
+ 'rich' : {
89
+ 'style' : 'green',
92
90
  },
93
- 'color' : [
91
+ 'color' : [
94
92
  'green',
95
93
  ],
96
94
  },
97
- 'disconnected' : {
98
- 'rich' : {
99
- 'style' : 'red',
95
+ 'disconnected' : {
96
+ 'rich' : {
97
+ 'style' : 'red',
100
98
  },
101
- 'color' : [
99
+ 'color' : [
100
+ 'red',
101
+ ],
102
+ },
103
+ 'update_message' : {
104
+ 'rich' : {
105
+ 'style' : 'red',
106
+ },
107
+ 'color' : [
102
108
  'red',
103
109
  ],
104
110
  },
105
111
  },
106
- 'ascii' : {
107
- 'intro' : """ ___ ___ __ __ __
112
+ 'ascii' : {
113
+ 'intro' : r""" ___ ___ __ __ __
108
114
  |\/| |__ |__ |__) /__` / ` |__| /\ | | |\/|
109
115
  | | |___ |___ | \ .__/ \__, | | /~~\ \__/ | |\n""",
110
- 'prompt' : '\n [ {username}@{instance} ] > ',
111
- 'ruler' : '-',
112
- 'close_message': 'Thank you for using Meerschaum!',
113
- 'doc_header' : 'Meerschaum actions (`help <action>` for usage):',
114
- 'undoc_header' : 'Unimplemented actions:',
116
+ 'prompt' : '\n [ {username}@{instance} ] > ',
117
+ 'ruler' : '-',
118
+ 'close_message' : 'Thank you for using Meerschaum!',
119
+ 'doc_header' : 'Meerschaum actions (`help <action>` for usage):',
120
+ 'undoc_header' : 'Unimplemented actions:',
121
+ 'update_message' : "Update available!",
115
122
  },
116
- 'unicode' : {
117
- 'intro' : """
123
+ 'unicode' : {
124
+ 'intro' : """
118
125
  █▄ ▄█ ██▀ ██▀ █▀▄ ▄▀▀ ▄▀▀ █▄█ ▄▀▄ █ █ █▄ ▄█
119
126
  █ ▀ █ █▄▄ █▄▄ █▀▄ ▄██ ▀▄▄ █ █ █▀█ ▀▄█ █ ▀ █\n""",
120
- 'prompt' : '\n [ {username}@{instance} ] ➤ ',
121
- 'ruler' : '─',
122
- 'close_message': ' MRSM{formatting:emoji:hand} Thank you for using Meerschaum! ',
123
- 'doc_header' : 'Meerschaum actions (`help <action>` for usage):',
124
- 'undoc_header' : 'Unimplemented actions:',
127
+ 'prompt' : '\n [ {username}@{instance} ] ➤ ',
128
+ 'ruler' : '─',
129
+ 'close_message' : ' MRSM{formatting:emoji:hand} Thank you for using Meerschaum! ',
130
+ 'doc_header' : 'Meerschaum actions (`help <action>` for usage):',
131
+ 'undoc_header' : 'Unimplemented actions:',
132
+ 'update_message' : "MRSM{formatting:emoji:announcement} Update available!",
133
+ },
134
+ 'timeout' : 60,
135
+ 'max_history' : 1000,
136
+ 'clear_screen' : True,
137
+ 'bottom_toolbar' : {
138
+ 'enabled' : True,
125
139
  },
126
- 'timeout' : 60,
127
- 'max_history' : 1000,
128
- 'clear_screen' : True,
129
- 'bottom_toolbar' : {
130
- 'enabled' : True,
140
+ 'updates' : {
141
+ 'check_remote' : True,
142
+ 'refresh_minutes': 180,
131
143
  },
132
144
  }
@@ -2,4 +2,4 @@
2
2
  Specify the Meerschaum release version.
3
3
  """
4
4
 
5
- __version__ = "2.2.5.dev3"
5
+ __version__ = "2.2.7"
@@ -6,5 +6,24 @@
6
6
  External API for importing Meerschaum paths.
7
7
  """
8
8
 
9
- from meerschaum.config._paths import __getattr__, paths
10
- __all__ = tuple(paths.keys())
9
+ import pathlib
10
+ import inspect
11
+ import meerschaum.config._paths as _paths
12
+
13
+
14
+ def __getattr__(*args, **kwargs):
15
+ return _paths.__getattr__(*args, **kwargs)
16
+
17
+
18
+ _globals_dict = inspect.getmembers(
19
+ _paths,
20
+ lambda member: not inspect.isroutine(member)
21
+ )
22
+ _all_caps_globals = [
23
+ name
24
+ for name, value in _globals_dict
25
+ if ('PATH' in name or 'FILE' in name) and not name.startswith('_')
26
+ and isinstance(value, pathlib.Path)
27
+ ]
28
+
29
+ __all__ = tuple(_all_caps_globals + list(_paths.paths.keys()))
@@ -39,6 +39,7 @@ STATIC_CONFIG: Dict[str, Any] = {
39
39
  'token_expires_minutes': 720,
40
40
  },
41
41
  'webterm_job_name': '_webterm',
42
+ 'default_timeout': 600,
42
43
  },
43
44
  'sql': {
44
45
  'internal_schema': '_mrsm_internal',
@@ -46,6 +47,7 @@ STATIC_CONFIG: Dict[str, Any] = {
46
47
  },
47
48
  'environment': {
48
49
  'config': 'MRSM_CONFIG',
50
+ 'config_dir': 'MRSM_CONFIG_DIR',
49
51
  'patch': 'MRSM_PATCH',
50
52
  'root': 'MRSM_ROOT_DIR',
51
53
  'plugins': 'MRSM_PLUGINS_DIR',
@@ -18,7 +18,7 @@ class InvalidAttributesError(Exception):
18
18
 
19
19
  class Connector(metaclass=abc.ABCMeta):
20
20
  """
21
- The base connector class to hold connection attributes,
21
+ The base connector class to hold connection attributes.
22
22
  """
23
23
  def __init__(
24
24
  self,
@@ -27,6 +27,8 @@ class Connector(metaclass=abc.ABCMeta):
27
27
  **kw: Any
28
28
  ):
29
29
  """
30
+ Set the given keyword arguments as attributes.
31
+
30
32
  Parameters
31
33
  ----------
32
34
  type: str
@@ -35,9 +37,12 @@ class Connector(metaclass=abc.ABCMeta):
35
37
  label: str
36
38
  The `label` for the connector.
37
39
 
40
+
41
+ Examples
42
+ --------
38
43
  Run `mrsm edit config` and to edit connectors in the YAML file:
39
44
 
40
- ```
45
+ ```yaml
41
46
  meerschaum:
42
47
  connections:
43
48
  {type}:
@@ -24,6 +24,7 @@ from meerschaum.connectors.api.APIConnector import APIConnector
24
24
  from meerschaum.connectors.sql._create_engine import flavor_configs as sql_flavor_configs
25
25
 
26
26
  __all__ = (
27
+ "make_connector",
27
28
  "Connector",
28
29
  "SQLConnector",
29
30
  "APIConnector",
@@ -290,13 +291,14 @@ def make_connector(
290
291
  --------
291
292
  >>> import meerschaum as mrsm
292
293
  >>> from meerschaum.connectors import make_connector, Connector
294
+ >>>
295
+ >>> @make_connector
293
296
  >>> class FooConnector(Connector):
294
- ... def __init__(self, label: str, **kw):
295
- ... super().__init__('foo', label, **kw)
297
+ ... REQUIRED_ATTRIBUTES: list[str] = ['username', 'password']
296
298
  ...
297
- >>> make_connector(FooConnector)
298
- >>> mrsm.get_connector('foo', 'bar')
299
- foo:bar
299
+ >>> conn = mrsm.get_connector('foo:bar', username='dog', password='cat')
300
+ >>> print(conn.username, conn.password)
301
+ dog cat
300
302
  >>>
301
303
  """
302
304
  import re
@@ -83,12 +83,16 @@ class APIConnector(Connector):
83
83
  if 'uri' in kw:
84
84
  from_uri_params = self.from_uri(kw['uri'], as_dict=True)
85
85
  label = label or from_uri_params.get('label', None)
86
- from_uri_params.pop('label', None)
86
+ _ = from_uri_params.pop('label', None)
87
87
  kw.update(from_uri_params)
88
88
 
89
89
  super().__init__('api', label=label, **kw)
90
90
  if 'protocol' not in self.__dict__:
91
- self.protocol = 'http'
91
+ self.protocol = (
92
+ 'https' if self.__dict__.get('uri', '').startswith('https')
93
+ else 'http'
94
+ )
95
+
92
96
  if 'uri' not in self.__dict__:
93
97
  self.verify_attributes(required_attributes)
94
98
  else:
@@ -97,6 +101,7 @@ class APIConnector(Connector):
97
101
  if 'host' not in conn_attrs:
98
102
  raise Exception(f"Invalid URI for '{self}'.")
99
103
  self.__dict__.update(conn_attrs)
104
+
100
105
  self.url = (
101
106
  self.protocol + '://' +
102
107
  self.host
@@ -9,44 +9,31 @@ Functions to interact with /mrsm/actions
9
9
  from __future__ import annotations
10
10
  from meerschaum.utils.typing import SuccessTuple, Optional, List
11
11
 
12
- def get_actions(
13
- self,
14
- ) -> list:
15
- """Get available actions from the API server"""
12
+ def get_actions(self) -> list:
13
+ """Get available actions from the API instance."""
16
14
  from meerschaum.config.static import STATIC_CONFIG
17
15
  return self.get(STATIC_CONFIG['api']['endpoints']['actions'])
18
16
 
19
17
 
20
18
  def do_action(
21
- self,
22
- action: Optional[List[str]] = None,
23
- sysargs: Optional[List[str]] = None,
24
- debug: bool = False,
25
- **kw
26
- ) -> SuccessTuple:
19
+ self,
20
+ action: Optional[List[str]] = None,
21
+ sysargs: Optional[List[str]] = None,
22
+ debug: bool = False,
23
+ **kw
24
+ ) -> SuccessTuple:
27
25
  """Execute a Meerschaum action remotely.
28
-
29
- If sysargs is provided, parse those instead. Otherwise infer everything from keyword arguments.
30
-
31
- NOTE: The first index of `action` should NOT be removed!
32
- Example: action = ['show', 'config']
33
-
34
- Returns: tuple (succeeded : bool, message : str)
35
26
 
36
- Parameters
37
- ----------
38
- action: Optional[List[str]] :
39
- (Default value = None)
40
- sysargs: Optional[List[str]] :
41
- (Default value = None)
42
- debug: bool :
43
- (Default value = False)
44
- **kw :
45
-
46
-
47
- Returns
48
- -------
27
+ If `sysargs` are provided, parse those instead.
28
+ Otherwise infer everything from keyword arguments.
49
29
 
30
+ Examples
31
+ --------
32
+ >>> conn = mrsm.get_connector('api:main')
33
+ >>> conn.do_action(['show', 'pipes'])
34
+ (True, "Success")
35
+ >>> conn.do_action(['show', 'arguments'], name='test')
36
+ (True, "Success")
50
37
  """
51
38
  import sys, json
52
39
  from meerschaum.utils.debug import dprint
@@ -63,7 +50,12 @@ def do_action(
63
50
  else:
64
51
  json_dict = kw
65
52
  json_dict['action'] = action
66
- json_dict['debug'] = debug
53
+ if 'noask' not in kw:
54
+ json_dict['noask'] = True
55
+ if 'yes' not in kw:
56
+ json_dict['yes'] = True
57
+ if debug:
58
+ json_dict['debug'] = debug
67
59
 
68
60
  root_action = json_dict['action'][0]
69
61
  del json_dict['action'][0]
@@ -17,7 +17,7 @@ def get_mrsm_version(self, **kw) -> Optional[str]:
17
17
  try:
18
18
  j = self.get(
19
19
  STATIC_CONFIG['api']['endpoints']['version'] + '/mrsm',
20
- use_token = True,
20
+ use_token=False,
21
21
  **kw
22
22
  ).json()
23
23
  except Exception as e:
@@ -11,7 +11,7 @@ import urllib.parse
11
11
  import pathlib
12
12
  from meerschaum.utils.typing import Any, Optional, Dict, Union
13
13
  from meerschaum.utils.debug import dprint
14
- from meerschaum.utils.formatting import pprint
14
+ from meerschaum.config.static import STATIC_CONFIG
15
15
 
16
16
  METHODS = {
17
17
  'GET',
@@ -23,15 +23,16 @@ METHODS = {
23
23
  'DELETE',
24
24
  }
25
25
 
26
+
26
27
  def make_request(
27
- self,
28
- method: str,
29
- r_url: str,
30
- headers: Optional[Dict[str, Any]] = None,
31
- use_token: bool = True,
32
- debug: bool = False,
33
- **kwargs: Any
34
- ) -> 'requests.Response':
28
+ self,
29
+ method: str,
30
+ r_url: str,
31
+ headers: Optional[Dict[str, Any]] = None,
32
+ use_token: bool = True,
33
+ debug: bool = False,
34
+ **kwargs: Any
35
+ ) -> 'requests.Response':
35
36
  """
36
37
  Make a request to this APIConnector's endpoint using the in-memory session.
37
38
 
@@ -84,6 +85,9 @@ def make_request(
84
85
  if use_token:
85
86
  headers.update({'Authorization': f'Bearer {self.token}'})
86
87
 
88
+ if 'timeout' not in kwargs:
89
+ kwargs['timeout'] = STATIC_CONFIG['api']['default_timeout']
90
+
87
91
  request_url = urllib.parse.urljoin(self.url, r_url)
88
92
  if debug:
89
93
  dprint(f"[{self}] Sending a '{method.upper()}' request to {request_url}")
@@ -11,11 +11,11 @@ from meerschaum.utils.warnings import warn, error
11
11
 
12
12
  @classmethod
13
13
  def from_uri(
14
- cls,
15
- uri: str,
16
- label: Optional[str] = None,
17
- as_dict: bool = False,
18
- ) -> Union[
14
+ cls,
15
+ uri: str,
16
+ label: Optional[str] = None,
17
+ as_dict: bool = False,
18
+ ) -> Union[
19
19
  'meerschaum.connectors.APIConnector',
20
20
  Dict[str, Union[str, int]],
21
21
  ]:
@@ -50,6 +50,7 @@ with correct credentials, as well as a network connection and valid permissions.
50
50
  """
51
51
 
52
52
  from __future__ import annotations
53
+ import sys
53
54
  import copy
54
55
  from meerschaum.utils.typing import Optional, Dict, Any, Union, InstanceConnector, List
55
56
  from meerschaum.utils.formatting._pipes import pipe_repr
@@ -433,13 +434,16 @@ class Pipe:
433
434
  + str(self.instance_keys) + sep
434
435
  )
435
436
 
436
- def __repr__(self, **kw) -> str:
437
- return pipe_repr(self, **kw)
437
+ def __repr__(self, ansi: bool=True, **kw) -> str:
438
+ if not hasattr(sys, 'ps1'):
439
+ ansi = False
440
+
441
+ return pipe_repr(self, ansi=ansi, **kw)
438
442
 
439
443
  def __pt_repr__(self):
440
444
  from meerschaum.utils.packages import attempt_import
441
445
  prompt_toolkit_formatted_text = attempt_import('prompt_toolkit.formatted_text', lazy=False)
442
- return prompt_toolkit_formatted_text.ANSI(self.__repr__())
446
+ return prompt_toolkit_formatted_text.ANSI(pipe_repr(self, ansi=True))
443
447
 
444
448
  def __getstate__(self) -> Dict[str, Any]:
445
449
  """
@@ -8,24 +8,32 @@ Retrieve Pipes' data from instances.
8
8
 
9
9
  from __future__ import annotations
10
10
  from datetime import datetime, timedelta
11
- from meerschaum.utils.typing import Optional, Dict, Any, Union, Generator, List, Tuple, Iterator
11
+
12
+ import meerschaum as mrsm
13
+ from meerschaum.utils.typing import (
14
+ Optional, Dict, Any, Union, List, Tuple, Iterator, TYPE_CHECKING,
15
+ )
12
16
  from meerschaum.config import get_config
13
17
 
18
+ if TYPE_CHECKING:
19
+ pd = mrsm.attempt_import('pandas')
20
+
21
+
14
22
  def get_data(
15
- self,
16
- select_columns: Optional[List[str]] = None,
17
- omit_columns: Optional[List[str]] = None,
18
- begin: Union[datetime, int, None] = None,
19
- end: Union[datetime, int, None] = None,
20
- params: Optional[Dict[str, Any]] = None,
21
- as_iterator: bool = False,
22
- as_chunks: bool = False,
23
- as_dask: bool = False,
24
- chunk_interval: Union[timedelta, int, None] = None,
25
- fresh: bool = False,
26
- debug: bool = False,
27
- **kw: Any
28
- ) -> Union['pd.DataFrame', Generator['pd.DataFrame'], None]:
23
+ self,
24
+ select_columns: Optional[List[str]] = None,
25
+ omit_columns: Optional[List[str]] = None,
26
+ begin: Union[datetime, int, None] = None,
27
+ end: Union[datetime, int, None] = None,
28
+ params: Optional[Dict[str, Any]] = None,
29
+ as_iterator: bool = False,
30
+ as_chunks: bool = False,
31
+ as_dask: bool = False,
32
+ chunk_interval: Union[timedelta, int, None] = None,
33
+ fresh: bool = False,
34
+ debug: bool = False,
35
+ **kw: Any
36
+ ) -> Union['pd.DataFrame', Iterator['pd.DataFrame'], None]:
29
37
  """
30
38
  Get a pipe's data from the instance connector.
31
39
 
@@ -8,7 +8,7 @@ Delete duplicate rows within a pipe's table.
8
8
 
9
9
  from __future__ import annotations
10
10
  from datetime import datetime, timedelta
11
- from meerschaum.utils.typing import SuccessTuple, Any, Optional, Dict, Tuple
11
+ from meerschaum.utils.typing import SuccessTuple, Any, Optional, Dict, Tuple, Union
12
12
 
13
13
 
14
14
  def deduplicate(
@@ -8,7 +8,12 @@ Enforce data types for a pipe's underlying table.
8
8
 
9
9
  from __future__ import annotations
10
10
  from io import StringIO
11
+ import meerschaum as mrsm
11
12
  from meerschaum.utils.typing import Dict, Any, Optional
13
+ from typing import TYPE_CHECKING
14
+
15
+ if TYPE_CHECKING:
16
+ pd = mrsm.attempt_import('pandas')
12
17
 
13
18
  def enforce_dtypes(
14
19
  self,