langflow-base-nightly 0.5.0.dev15__py3-none-any.whl → 0.5.0.dev16__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.
langflow/__main__.py CHANGED
@@ -188,6 +188,7 @@ def run(
188
188
  show_default=False,
189
189
  ),
190
190
  log_file: Path | None = typer.Option(None, help="Path to the log file.", show_default=False),
191
+ log_rotation: str | None = typer.Option(None, help="Log rotation(Time/Size).", show_default=False),
191
192
  cache: str | None = typer.Option( # noqa: ARG001
192
193
  None,
193
194
  help="Type of cache to use. (InMemoryCache, SQLiteCache)",
@@ -263,7 +264,7 @@ def run(
263
264
  else:
264
265
  os.environ["LANGFLOW_LOG_LEVEL"] = env_log_level.lower()
265
266
 
266
- configure(log_level=log_level, log_file=log_file)
267
+ configure(log_level=log_level, log_file=log_file, log_rotation=log_rotation)
267
268
 
268
269
  # Create progress indicator (show verbose timing if log level is DEBUG)
269
270
  verbose = log_level == "debug"
langflow/load/load.py CHANGED
@@ -21,6 +21,7 @@ async def aload_flow_from_json(
21
21
  tweaks: dict | None = None,
22
22
  log_level: str | None = None,
23
23
  log_file: str | None = None,
24
+ log_rotation: str | None = None,
24
25
  env_file: str | None = None,
25
26
  cache: str | None = None,
26
27
  disable_logs: bool | None = True,
@@ -33,6 +34,7 @@ async def aload_flow_from_json(
33
34
  tweaks (Optional[dict]): Optional tweaks to apply to the loaded flow graph.
34
35
  log_level (Optional[str]): Optional log level to configure for the flow processing.
35
36
  log_file (Optional[str]): Optional log file to configure for the flow processing.
37
+ log_rotation (Optional[str]): Optional log rotation(Time/Size) to configure for the flow processing.
36
38
  env_file (Optional[str]): Optional .env file to override environment variables.
37
39
  cache (Optional[str]): Optional cache path to update the flow settings.
38
40
  disable_logs (Optional[bool], default=True): Optional flag to disable logs during flow processing.
@@ -47,7 +49,9 @@ async def aload_flow_from_json(
47
49
  """
48
50
  # If input is a file path, load JSON from the file
49
51
  log_file_path = Path(log_file) if log_file else None
50
- configure(log_level=log_level, log_file=log_file_path, disable=disable_logs, async_file=True)
52
+ configure(
53
+ log_level=log_level, log_file=log_file_path, disable=disable_logs, async_file=True, log_rotation=log_rotation
54
+ )
51
55
 
52
56
  # override env variables with .env file
53
57
  if env_file and tweaks is not None:
@@ -83,6 +87,7 @@ def load_flow_from_json(
83
87
  tweaks: dict | None = None,
84
88
  log_level: str | None = None,
85
89
  log_file: str | None = None,
90
+ log_rotation: str | None = None,
86
91
  env_file: str | None = None,
87
92
  cache: str | None = None,
88
93
  disable_logs: bool | None = True,
@@ -95,6 +100,7 @@ def load_flow_from_json(
95
100
  tweaks (Optional[dict]): Optional tweaks to apply to the loaded flow graph.
96
101
  log_level (Optional[str]): Optional log level to configure for the flow processing.
97
102
  log_file (Optional[str]): Optional log file to configure for the flow processing.
103
+ log_rotation (Optional[str]): Optional log rotation(Time/Size) to configure for the flow processing.
98
104
  env_file (Optional[str]): Optional .env file to override environment variables.
99
105
  cache (Optional[str]): Optional cache path to update the flow settings.
100
106
  disable_logs (Optional[bool], default=True): Optional flag to disable logs during flow processing.
@@ -113,6 +119,7 @@ def load_flow_from_json(
113
119
  tweaks=tweaks,
114
120
  log_level=log_level,
115
121
  log_file=log_file,
122
+ log_rotation=log_rotation,
116
123
  env_file=env_file,
117
124
  cache=cache,
118
125
  disable_logs=disable_logs,
@@ -131,6 +138,7 @@ async def arun_flow_from_json(
131
138
  output_component: str | None = None,
132
139
  log_level: str | None = None,
133
140
  log_file: str | None = None,
141
+ log_rotation: str | None = None,
134
142
  env_file: str | None = None,
135
143
  cache: str | None = None,
136
144
  disable_logs: bool | None = True,
@@ -148,6 +156,7 @@ async def arun_flow_from_json(
148
156
  output_component (Optional[str], optional): The specific component to output. Defaults to None.
149
157
  log_level (Optional[str], optional): The log level to use. Defaults to None.
150
158
  log_file (Optional[str], optional): The log file to write logs to. Defaults to None.
159
+ log_rotation (Optional[str], optional): The log rotation to use. Defaults to None.
151
160
  env_file (Optional[str], optional): The environment file to load. Defaults to None.
152
161
  cache (Optional[str], optional): The cache directory to use. Defaults to None.
153
162
  disable_logs (Optional[bool], optional): Whether to disable logs. Defaults to True.
@@ -165,6 +174,7 @@ async def arun_flow_from_json(
165
174
  tweaks=tweaks,
166
175
  log_level=log_level,
167
176
  log_file=log_file,
177
+ log_rotation=log_rotation,
168
178
  env_file=env_file,
169
179
  cache=cache,
170
180
  disable_logs=disable_logs,
@@ -193,6 +203,7 @@ def run_flow_from_json(
193
203
  output_component: str | None = None,
194
204
  log_level: str | None = None,
195
205
  log_file: str | None = None,
206
+ log_rotation: str | None = None,
196
207
  env_file: str | None = None,
197
208
  cache: str | None = None,
198
209
  disable_logs: bool | None = True,
@@ -214,6 +225,7 @@ def run_flow_from_json(
214
225
  output_component (Optional[str], optional): The specific component to output. Defaults to None.
215
226
  log_level (Optional[str], optional): The log level to use. Defaults to None.
216
227
  log_file (Optional[str], optional): The log file to write logs to. Defaults to None.
228
+ log_rotation (Optional[str], optional): The log rotation to use. Defaults to None.
217
229
  env_file (Optional[str], optional): The environment file to load. Defaults to None.
218
230
  cache (Optional[str], optional): The cache directory to use. Defaults to None.
219
231
  disable_logs (Optional[bool], optional): Whether to disable logs. Defaults to True.
@@ -234,6 +246,7 @@ def run_flow_from_json(
234
246
  output_component=output_component,
235
247
  log_level=log_level,
236
248
  log_file=log_file,
249
+ log_rotation=log_rotation,
237
250
  env_file=env_file,
238
251
  cache=cache,
239
252
  disable_logs=disable_logs,
@@ -1,4 +1,3 @@
1
- import asyncio
2
1
  import json
3
2
  import logging
4
3
  import os
@@ -9,10 +8,7 @@ from threading import Lock, Semaphore
9
8
  from typing import TypedDict
10
9
 
11
10
  import orjson
12
- from loguru import _defaults, logger
13
- from loguru._error_interceptor import ErrorInterceptor
14
- from loguru._file_sink import FileSink
15
- from loguru._simple_sinks import AsyncSink
11
+ from loguru import logger
16
12
  from platformdirs import user_cache_dir
17
13
  from rich.logging import RichHandler
18
14
  from typing_extensions import NotRequired, override
@@ -154,24 +150,6 @@ class LogConfig(TypedDict):
154
150
  log_format: NotRequired[str]
155
151
 
156
152
 
157
- class AsyncFileSink(AsyncSink):
158
- def __init__(self, file):
159
- self._sink = FileSink(
160
- path=file,
161
- rotation="10 MB", # Log rotation based on file size
162
- delay=True,
163
- )
164
- super().__init__(self.write_async, None, ErrorInterceptor(_defaults.LOGURU_CATCH, -1))
165
-
166
- async def complete(self):
167
- await asyncio.to_thread(self._sink.stop)
168
- for task in self._tasks:
169
- await self._complete_task(task)
170
-
171
- async def write_async(self, message):
172
- await asyncio.to_thread(self._sink.write, message)
173
-
174
-
175
153
  def is_valid_log_format(format_string) -> bool:
176
154
  """Validates a logging format string by attempting to format it with a dummy LogRecord.
177
155
 
@@ -204,6 +182,7 @@ def configure(
204
182
  log_env: str | None = None,
205
183
  log_format: str | None = None,
206
184
  async_file: bool = False,
185
+ log_rotation: str | None = None,
207
186
  ) -> None:
208
187
  if disable and log_level is None and log_file is None:
209
188
  logger.disable("langflow")
@@ -252,12 +231,20 @@ def configure(
252
231
  logger.debug(f"Cache directory: {cache_dir}")
253
232
  log_file = cache_dir / "langflow.log"
254
233
  logger.debug(f"Log file: {log_file}")
234
+
235
+ if os.getenv("LANGFLOW_LOG_ROTATION") and log_rotation is None:
236
+ log_rotation = os.getenv("LANGFLOW_LOG_ROTATION")
237
+ elif log_rotation is None:
238
+ log_rotation = "1 day"
239
+
255
240
  try:
256
241
  logger.add(
257
- sink=AsyncFileSink(log_file) if async_file else log_file,
242
+ sink=log_file,
258
243
  level=log_level.upper(),
259
244
  format=log_format,
260
245
  serialize=True,
246
+ enqueue=async_file,
247
+ rotation=log_rotation,
261
248
  )
262
249
  except Exception: # noqa: BLE001
263
250
  logger.exception("Error setting up log file")
@@ -46,12 +46,19 @@ class LangflowRunnerExperimental:
46
46
  should_initialize_db: bool = True,
47
47
  log_level: str | None = None,
48
48
  log_file: str | None = None,
49
+ log_rotation: str | None = None,
49
50
  disable_logs: bool = False,
50
51
  async_log_file: bool = True,
51
52
  ):
52
53
  self.should_initialize_db = should_initialize_db
53
54
  log_file_path = Path(log_file) if log_file else None
54
- configure(log_level=log_level, log_file=log_file_path, disable=disable_logs, async_file=async_log_file)
55
+ configure(
56
+ log_level=log_level,
57
+ log_file=log_file_path,
58
+ log_rotation=log_rotation,
59
+ disable=disable_logs,
60
+ async_file=async_log_file,
61
+ )
55
62
 
56
63
  async def run(
57
64
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langflow-base-nightly
3
- Version: 0.5.0.dev15
3
+ Version: 0.5.0.dev16
4
4
  Summary: A Python package with a built-in web application
5
5
  Project-URL: Repository, https://github.com/langflow-ai/langflow
6
6
  Project-URL: Documentation, https://docs.langflow.org
@@ -1,5 +1,5 @@
1
1
  langflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- langflow/__main__.py,sha256=eG7QJmwn-96jRHaFgHEn3XoQCUubLulP-EkJvtbG2MQ,32152
2
+ langflow/__main__.py,sha256=80Jc0iW3DjkwRG_oDqHH9RkzJIakyCrPGvl_Zvhzaqc,32283
3
3
  langflow/alembic.ini,sha256=fbUkg3Y988q24z9FRya85qBQBvKvEI8fQbR4CsWHHsk,3503
4
4
  langflow/langflow_launcher.py,sha256=ruVUD-ZXb-Bi9xtXYu17rXuwBr6OmPMF46mH-hPbfpQ,1984
5
5
  langflow/main.py,sha256=20UgLEpbG__xbT3zqQNvLsP2mYtjZcvNsGaAvUxWD3c,18195
@@ -912,10 +912,10 @@ langflow/io/schema.py,sha256=b_hJrEaSXStr5BHnls1XA4J-YpMO3VTd0RTAps275do,10982
912
912
  langflow/legacy_custom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
913
913
  langflow/legacy_custom/customs.py,sha256=gEGcyCfxYBt47JUbujFBJaTWL47VnTtrQhX_pY9wQJw,496
914
914
  langflow/load/__init__.py,sha256=ITIgga_5DG6hifCvrUfb0ayuI8Z1OH-t4Xbcs5w_VLk,356
915
- langflow/load/load.py,sha256=NACAgR37fMNiRIT53F_Sx8v7jAv70-I7jVtY2ZEAHzc,9788
915
+ langflow/load/load.py,sha256=-C4YgaGhkq887Ee7RY-ypqnLfCZrQq7YHwikEtrbA0E,10490
916
916
  langflow/load/utils.py,sha256=QNdCi1kWZ7NAP1ygBymE8v7dzmUSwOd8pPoOsgNa6v4,4550
917
917
  langflow/logging/__init__.py,sha256=BxbXuZt3Q4osYLK4CsjbKNs7P79n_kyQk9D5IK4LG1A,174
918
- langflow/logging/logger.py,sha256=PnMiFbhL_NmsDKqu4SjSaAf3A8W9Q0ysjAidd_uIU9k,10104
918
+ langflow/logging/logger.py,sha256=623che7ol26JknNNZON7U7no0w4sizwv2CB6t5f_9uU,9645
919
919
  langflow/logging/setup.py,sha256=cgfMl4vXJZyYWSw1sNdmsltpZyUjx2TjZOVx1V5gciY,373
920
920
  langflow/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
921
921
  langflow/processing/process.py,sha256=kVyvv26PYgWAaT2iM90hevBGyyodj-XtLlOmALinUIM,8562
@@ -1001,7 +1001,7 @@ langflow/services/database/models/vertex_builds/__init__.py,sha256=fHWjmTkwb4hNg
1001
1001
  langflow/services/database/models/vertex_builds/crud.py,sha256=TS9RZUZ8o5ogLZpFlp3U5MF-D2owaR7TlWrhSOzjxb4,5537
1002
1002
  langflow/services/database/models/vertex_builds/model.py,sha256=JjLWNr99IuPQam-7ZMmqLvBZkqwBeVVETGMkTTsp4-U,3152
1003
1003
  langflow/services/flow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1004
- langflow/services/flow/flow_runner.py,sha256=eZhlorQ-VTzkJ8MogjhB48o37xmZMcYO1t0WYLozHYw,10154
1004
+ langflow/services/flow/flow_runner.py,sha256=vNnQOQn_Nligfyp7uzmPDqalGdkPAtKEU-HlPjmFGGM,10293
1005
1005
  langflow/services/job_queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1006
1006
  langflow/services/job_queue/factory.py,sha256=G8Ow87wXa5SIaxZdmbHt4fJO636yT5u0IU4dz0_pieo,341
1007
1007
  langflow/services/job_queue/service.py,sha256=L4vmzyHNcdIlO5Ur6c4h29gFUk2ekCuJUmJDC-RrfDY,14035
@@ -1104,7 +1104,7 @@ langflow/utils/util_strings.py,sha256=Blz5lwvE7lml7nKCG9vVJ6me5VNmVtYzFXDVPHPK7v
1104
1104
  langflow/utils/validate.py,sha256=lJvgYUMk6EwEJYLnCWCA81TQZFan7bVIWBDJZLwoFZQ,14390
1105
1105
  langflow/utils/version.py,sha256=OjSj0smls9XnPd4-LpTH9AWyUO_NAn5mncqKkkXl_fw,2840
1106
1106
  langflow/utils/voice_utils.py,sha256=pzU6uuseI2_5mi-yXzFIjMavVRFyuVrpLmR6LqbF7mE,3346
1107
- langflow_base_nightly-0.5.0.dev15.dist-info/METADATA,sha256=oNKWxhS028nGGQSDEG_PabGI_0C7iWnCRZAMd0FMIUY,4173
1108
- langflow_base_nightly-0.5.0.dev15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1109
- langflow_base_nightly-0.5.0.dev15.dist-info/entry_points.txt,sha256=JvuLdXSrkeDmDdpb8M-VvFIzb84n4HmqUcIP10_EIF8,57
1110
- langflow_base_nightly-0.5.0.dev15.dist-info/RECORD,,
1107
+ langflow_base_nightly-0.5.0.dev16.dist-info/METADATA,sha256=Ymdd0utL3BtR6_Hsq7bvYw2cwrF1EV5_52DnB4kCRTo,4173
1108
+ langflow_base_nightly-0.5.0.dev16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1109
+ langflow_base_nightly-0.5.0.dev16.dist-info/entry_points.txt,sha256=JvuLdXSrkeDmDdpb8M-VvFIzb84n4HmqUcIP10_EIF8,57
1110
+ langflow_base_nightly-0.5.0.dev16.dist-info/RECORD,,