hyperpocket 0.1.10__py3-none-any.whl → 0.2.0__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 (92) hide show
  1. hyperpocket/__init__.py +4 -4
  2. hyperpocket/auth/__init__.py +12 -7
  3. hyperpocket/auth/calendly/oauth2_handler.py +24 -17
  4. hyperpocket/auth/calendly/oauth2_schema.py +3 -1
  5. hyperpocket/auth/context.py +2 -1
  6. hyperpocket/auth/github/oauth2_handler.py +13 -8
  7. hyperpocket/auth/github/token_handler.py +27 -21
  8. hyperpocket/auth/google/context.py +1 -3
  9. hyperpocket/auth/google/oauth2_context.py +1 -1
  10. hyperpocket/auth/google/oauth2_handler.py +22 -17
  11. hyperpocket/auth/gumloop/token_context.py +1 -4
  12. hyperpocket/auth/gumloop/token_handler.py +48 -20
  13. hyperpocket/auth/gumloop/token_schema.py +2 -1
  14. hyperpocket/auth/handler.py +21 -6
  15. hyperpocket/auth/linear/token_context.py +2 -5
  16. hyperpocket/auth/linear/token_handler.py +45 -21
  17. hyperpocket/auth/notion/context.py +2 -2
  18. hyperpocket/auth/notion/token_context.py +2 -4
  19. hyperpocket/auth/notion/token_handler.py +45 -21
  20. hyperpocket/auth/notion/token_schema.py +0 -1
  21. hyperpocket/auth/reddit/oauth2_handler.py +9 -10
  22. hyperpocket/auth/reddit/oauth2_schema.py +0 -2
  23. hyperpocket/auth/schema.py +4 -1
  24. hyperpocket/auth/slack/oauth2_context.py +3 -1
  25. hyperpocket/auth/slack/oauth2_handler.py +55 -35
  26. hyperpocket/auth/slack/token_context.py +2 -4
  27. hyperpocket/auth/slack/token_handler.py +42 -19
  28. hyperpocket/builtin.py +4 -2
  29. hyperpocket/cli/__main__.py +4 -2
  30. hyperpocket/cli/auth.py +59 -28
  31. hyperpocket/cli/codegen/auth/auth_context_template.py +3 -2
  32. hyperpocket/cli/codegen/auth/auth_token_context_template.py +3 -2
  33. hyperpocket/cli/codegen/auth/auth_token_handler_template.py +6 -5
  34. hyperpocket/cli/codegen/auth/auth_token_schema_template.py +3 -2
  35. hyperpocket/cli/codegen/auth/server_auth_template.py +3 -2
  36. hyperpocket/cli/pull.py +5 -5
  37. hyperpocket/config/__init__.py +3 -8
  38. hyperpocket/config/auth.py +3 -1
  39. hyperpocket/config/logger.py +20 -15
  40. hyperpocket/config/session.py +4 -2
  41. hyperpocket/config/settings.py +19 -2
  42. hyperpocket/futures/__init__.py +1 -1
  43. hyperpocket/futures/futurestore.py +3 -2
  44. hyperpocket/pocket_auth.py +171 -84
  45. hyperpocket/pocket_core.py +51 -33
  46. hyperpocket/pocket_main.py +122 -93
  47. hyperpocket/prompts.py +2 -2
  48. hyperpocket/repository/__init__.py +1 -1
  49. hyperpocket/repository/lock.py +47 -33
  50. hyperpocket/repository/lockfile.py +2 -2
  51. hyperpocket/repository/repository.py +1 -1
  52. hyperpocket/server/__init__.py +1 -1
  53. hyperpocket/server/auth/github.py +2 -1
  54. hyperpocket/server/auth/linear.py +1 -3
  55. hyperpocket/server/auth/notion.py +2 -5
  56. hyperpocket/server/auth/slack.py +1 -3
  57. hyperpocket/server/auth/token.py +17 -11
  58. hyperpocket/server/proxy.py +29 -13
  59. hyperpocket/server/server.py +75 -31
  60. hyperpocket/server/tool/dto/script.py +15 -10
  61. hyperpocket/server/tool/wasm.py +14 -11
  62. hyperpocket/session/__init__.py +6 -2
  63. hyperpocket/session/in_memory.py +44 -24
  64. hyperpocket/session/interface.py +42 -24
  65. hyperpocket/session/redis.py +48 -31
  66. hyperpocket/tool/__init__.py +10 -10
  67. hyperpocket/tool/function/__init__.py +1 -5
  68. hyperpocket/tool/function/annotation.py +11 -9
  69. hyperpocket/tool/function/tool.py +37 -27
  70. hyperpocket/tool/tool.py +59 -36
  71. hyperpocket/tool/wasm/__init__.py +1 -1
  72. hyperpocket/tool/wasm/browser.py +15 -10
  73. hyperpocket/tool/wasm/invoker.py +16 -16
  74. hyperpocket/tool/wasm/script.py +27 -14
  75. hyperpocket/tool/wasm/templates/__init__.py +22 -15
  76. hyperpocket/tool/wasm/templates/node.py +2 -2
  77. hyperpocket/tool/wasm/templates/python.py +2 -2
  78. hyperpocket/tool/wasm/tool.py +27 -14
  79. hyperpocket/tool_like.py +3 -3
  80. hyperpocket/util/__init__.py +1 -1
  81. hyperpocket/util/extract_func_param_desc_from_docstring.py +23 -7
  82. hyperpocket/util/find_all_leaf_class_in_package.py +4 -3
  83. hyperpocket/util/find_all_subclass_in_package.py +4 -2
  84. hyperpocket/util/flatten_json_schema.py +10 -6
  85. hyperpocket/util/function_to_model.py +33 -12
  86. hyperpocket/util/get_objects_from_subpackage.py +1 -1
  87. hyperpocket/util/json_schema_to_model.py +14 -5
  88. {hyperpocket-0.1.10.dist-info → hyperpocket-0.2.0.dist-info}/METADATA +11 -5
  89. hyperpocket-0.2.0.dist-info/RECORD +137 -0
  90. hyperpocket-0.1.10.dist-info/RECORD +0 -137
  91. {hyperpocket-0.1.10.dist-info → hyperpocket-0.2.0.dist-info}/WHEEL +0 -0
  92. {hyperpocket-0.1.10.dist-info → hyperpocket-0.2.0.dist-info}/entry_points.txt +0 -0
@@ -1,19 +1,21 @@
1
1
  import click
2
2
 
3
+ from hyperpocket.cli.auth import create_token_auth_template
4
+ from hyperpocket.cli.eject import eject
3
5
  from hyperpocket.cli.pull import pull
4
6
  from hyperpocket.cli.sync import sync
5
- from hyperpocket.cli.eject import eject
6
- from hyperpocket.cli.auth import create_token_auth_template
7
7
 
8
8
 
9
9
  @click.group()
10
10
  def cli():
11
11
  pass
12
12
 
13
+
13
14
  @click.group()
14
15
  def devtool():
15
16
  pass
16
17
 
18
+
17
19
  cli.add_command(devtool)
18
20
  devtool.add_command(create_token_auth_template)
19
21
 
hyperpocket/cli/auth.py CHANGED
@@ -1,23 +1,36 @@
1
1
  import os
2
- import click
3
2
  from pathlib import Path
4
- from hyperpocket.cli.codegen.auth import get_server_auth_token_template, get_auth_context_template, get_auth_token_context_template, get_auth_token_handler_template, get_auth_token_schema_template
3
+
4
+ import click
5
+
6
+ from hyperpocket.cli.codegen.auth import (
7
+ get_auth_context_template,
8
+ get_auth_token_context_template,
9
+ get_auth_token_handler_template,
10
+ get_auth_token_schema_template,
11
+ get_server_auth_token_template,
12
+ )
13
+
5
14
 
6
15
  @click.command()
7
- @click.argument('service_name', type=str)
16
+ @click.argument("service_name", type=str)
8
17
  def create_token_auth_template(service_name):
9
18
  ## Validate service_name
10
- if not service_name.islower() or not service_name.replace('_', '').isalpha():
11
- raise ValueError("service_name must be lowercase and contain only letters and underscores")
12
-
19
+ if not service_name.islower() or not service_name.replace("_", "").isalpha():
20
+ raise ValueError(
21
+ "service_name must be lowercase and contain only letters and underscores"
22
+ )
23
+
13
24
  capitliazed_service_name = service_name.capitalize()
14
- if '_' in service_name:
15
- capitliazed_service_name = ''.join([word.capitalize() for word in service_name.split('_')])
16
-
25
+ if "_" in service_name:
26
+ capitliazed_service_name = "".join(
27
+ [word.capitalize() for word in service_name.split("_")]
28
+ )
29
+
17
30
  ## Get the current working directory
18
31
  cwd = Path.cwd()
19
32
  parent_path = cwd.parent
20
-
33
+
21
34
  generate_server_auth(service_name, parent_path)
22
35
  generate_hyperpocket_auth_dir(service_name, parent_path)
23
36
  generate_auth_context(service_name, capitliazed_service_name, parent_path)
@@ -26,58 +39,76 @@ def create_token_auth_template(service_name):
26
39
  generate_auth_token_schema(service_name, capitliazed_service_name, parent_path)
27
40
  ##TODO: Add service to hyperpocket/auth/provider
28
41
 
42
+
29
43
  def generate_server_auth(service_name, parent_path):
30
44
  print(f"Generating server/auth for '{service_name}'.")
31
- output_from_parsed_template = get_server_auth_token_template().render(service_name=service_name)
32
- output_path = parent_path / f'hyperpocket/hyperpocket/server/auth/{service_name}.py'
45
+ output_from_parsed_template = get_server_auth_token_template().render(
46
+ service_name=service_name
47
+ )
48
+ output_path = parent_path / f"hyperpocket/hyperpocket/server/auth/{service_name}.py"
33
49
  with open(output_path, "w") as f:
34
50
  f.write(output_from_parsed_template)
35
51
 
52
+
36
53
  def generate_hyperpocket_auth_dir(service_name, parent_path):
37
- if not os.path.exists(parent_path / f'hyperpocket/hyperpocket/auth/{service_name}'):
38
- os.makedirs(parent_path / f'hyperpocket/hyperpocket/auth/{service_name}')
39
-
40
- output_path = parent_path / f'hyperpocket/hyperpocket/auth/{service_name}/__init__.py'
41
- with open(output_path, "w") as f:
54
+ if not os.path.exists(parent_path / f"hyperpocket/hyperpocket/auth/{service_name}"):
55
+ os.makedirs(parent_path / f"hyperpocket/hyperpocket/auth/{service_name}")
56
+
57
+ output_path = (
58
+ parent_path / f"hyperpocket/hyperpocket/auth/{service_name}/__init__.py"
59
+ )
60
+ with open(output_path, "w"):
42
61
  pass
43
62
 
63
+
44
64
  def generate_auth_context(service_name, capitliazed_service_name, parent_path):
45
65
  print(f"Generating auth/context for '{service_name}'.")
46
66
  output_from_parsed_template = get_auth_context_template().render(
47
- caplitalized_service_name=capitliazed_service_name,
48
- upper_service_name=service_name.upper()
67
+ caplitalized_service_name=capitliazed_service_name,
68
+ upper_service_name=service_name.upper(),
69
+ )
70
+ output_path = (
71
+ parent_path / f"hyperpocket/hyperpocket/auth/{service_name}/context.py"
49
72
  )
50
- output_path = parent_path / f'hyperpocket/hyperpocket/auth/{service_name}/context.py'
51
73
  with open(output_path, "w") as f:
52
74
  f.write(output_from_parsed_template)
53
75
 
76
+
54
77
  def generate_auth_token_context(service_name, capitliazed_service_name, parent_path):
55
78
  print(f"Generating auth/token context for '{service_name}'.")
56
79
  output_from_parsed_template = get_auth_token_context_template().render(
57
- service_name = service_name,
58
- caplitalized_service_name=capitliazed_service_name,
80
+ service_name=service_name,
81
+ caplitalized_service_name=capitliazed_service_name,
82
+ )
83
+ output_path = (
84
+ parent_path / f"hyperpocket/hyperpocket/auth/{service_name}/token_context.py"
59
85
  )
60
- output_path = parent_path / f'hyperpocket/hyperpocket/auth/{service_name}/token_context.py'
61
86
  with open(output_path, "w") as f:
62
87
  f.write(output_from_parsed_template)
63
88
 
89
+
64
90
  def generate_auth_token_handler(service_name, capitliazed_service_name, parent_path):
65
91
  print(f"Generating auth/token handler for '{service_name}'.")
66
92
  output_from_parsed_template = get_auth_token_handler_template().render(
67
- service_name = service_name,
68
- auth_handler_name = service_name.replace('_','-'),
93
+ service_name=service_name,
94
+ auth_handler_name=service_name.replace("_", "-"),
69
95
  caplitalized_service_name=capitliazed_service_name,
70
- upper_service_name=service_name.upper()
96
+ upper_service_name=service_name.upper(),
97
+ )
98
+ output_path = (
99
+ parent_path / f"hyperpocket/hyperpocket/auth/{service_name}/token_handler.py"
71
100
  )
72
- output_path = parent_path / f'hyperpocket/hyperpocket/auth/{service_name}/token_handler.py'
73
101
  with open(output_path, "w") as f:
74
102
  f.write(output_from_parsed_template)
75
103
 
104
+
76
105
  def generate_auth_token_schema(service_name, capitliazed_service_name, parent_path):
77
106
  print(f"Generating auth/token schema for '{service_name}'.")
78
107
  output_from_parsed_template = get_auth_token_schema_template().render(
79
108
  caplitalized_service_name=capitliazed_service_name,
80
109
  )
81
- output_path = parent_path / f'hyperpocket/hyperpocket/auth/{service_name}/token_schema.py'
110
+ output_path = (
111
+ parent_path / f"hyperpocket/hyperpocket/auth/{service_name}/token_schema.py"
112
+ )
82
113
  with open(output_path, "w") as f:
83
114
  f.write(output_from_parsed_template)
@@ -1,7 +1,8 @@
1
1
  from jinja2 import Template
2
2
 
3
+
3
4
  def get_auth_context_template() -> Template:
4
- return Template('''
5
+ return Template("""
5
6
  from hyperpocket.auth.context import AuthContext
6
7
  class {{ caplitalized_service_name }}AuthContext(AuthContext):
7
8
  _ACCESS_TOKEN_KEY: str = "{{ upper_service_name }}_TOKEN"
@@ -13,4 +14,4 @@ class {{ caplitalized_service_name }}AuthContext(AuthContext):
13
14
  return {
14
15
  f"{profile.upper()}_{self._ACCESS_TOKEN_KEY}": self.access_token,
15
16
  }
16
- ''')
17
+ """)
@@ -1,7 +1,8 @@
1
1
  from jinja2 import Template
2
2
 
3
+
3
4
  def get_auth_token_context_template() -> Template:
4
- return Template('''
5
+ return Template("""
5
6
  from hyperpocket.auth.{{ service_name }}.context import {{ caplitalized_service_name }}AuthContext
6
7
  from hyperpocket.auth.{{ service_name }}.token_schema import {{ caplitalized_service_name }}TokenResponse
7
8
  class {{ caplitalized_service_name }}TokenAuthContext({{ caplitalized_service_name }}AuthContext):
@@ -13,4 +14,4 @@ class {{ caplitalized_service_name }}TokenAuthContext({{ caplitalized_service_na
13
14
  description=description,
14
15
  expires_at=None
15
16
  )
16
- ''')
17
+ """)
@@ -1,7 +1,8 @@
1
1
  from jinja2 import Template
2
2
 
3
+
3
4
  def get_auth_token_handler_template() -> Template:
4
- return Template('''
5
+ return Template("""
5
6
  from typing import Optional
6
7
  from urllib.parse import urljoin, urlencode
7
8
 
@@ -19,7 +20,7 @@ class {{ caplitalized_service_name }}TokenAuthHandler(AuthHandlerInterface):
19
20
  description: str = "This handler is used to authenticate users using the {{ caplitalized_service_name }} token."
20
21
  scoped: bool = False
21
22
 
22
- _TOKEN_URL: str = urljoin(config.public_base_url + "/", f"{config.callback_url_rewrite_prefix}/auth/token")
23
+ _TOKEN_URL: str = urljoin(config().public_base_url + "/", f"{config().callback_url_rewrite_prefix}/auth/token")
23
24
 
24
25
  @staticmethod
25
26
  def provider() -> AuthProvider:
@@ -32,8 +33,8 @@ class {{ caplitalized_service_name }}TokenAuthHandler(AuthHandlerInterface):
32
33
  def prepare(self, auth_req: {{ caplitalized_service_name }}TokenRequest, thread_id: str, profile: str,
33
34
  future_uid: str, *args, **kwargs) -> str:
34
35
  redirect_uri = urljoin(
35
- config.public_base_url + "/",
36
- f"{config.callback_url_rewrite_prefix}/auth/{{ service_name }}/token/callback",
36
+ config().public_base_url + "/",
37
+ f"{config().callback_url_rewrite_prefix}/auth/{{ service_name }}/token/callback",
37
38
  )
38
39
  url = self._make_auth_url(auth_req=auth_req, redirect_uri=redirect_uri, state=future_uid)
39
40
  FutureStore.create_future(future_uid, data={
@@ -66,4 +67,4 @@ class {{ caplitalized_service_name }}TokenAuthHandler(AuthHandlerInterface):
66
67
 
67
68
  def make_request(self, auth_scopes: Optional[list[str]] = None, **kwargs) -> {{ caplitalized_service_name }}TokenRequest:
68
69
  return {{ caplitalized_service_name }}TokenRequest()
69
- ''')
70
+ """)
@@ -1,7 +1,8 @@
1
1
  from jinja2 import Template
2
2
 
3
+
3
4
  def get_auth_token_schema_template() -> Template:
4
- return Template('''
5
+ return Template("""
5
6
  from typing import List, Optional
6
7
  from pydantic import BaseModel
7
8
  from hyperpocket.auth.schema import AuthenticateRequest, AuthenticateResponse
@@ -9,4 +10,4 @@ class {{ caplitalized_service_name }}TokenRequest(AuthenticateRequest):
9
10
  pass
10
11
  class {{ caplitalized_service_name }}TokenResponse(AuthenticateResponse):
11
12
  access_token: str
12
- ''')
13
+ """)
@@ -1,7 +1,8 @@
1
1
  from jinja2 import Template
2
2
 
3
+
3
4
  def get_server_auth_token_template() -> Template:
4
- return Template('''
5
+ return Template("""
5
6
  from fastapi import APIRouter
6
7
  from starlette.responses import HTMLResponse
7
8
  from hyperpocket.futures import FutureStore
@@ -15,4 +16,4 @@ async def {{ service_name }}_token_callback(state: str, token: str):
15
16
  except ValueError:
16
17
  return HTMLResponse(content="failed")
17
18
  return HTMLResponse(content="success")
18
- ''')
19
+ """)
hyperpocket/cli/pull.py CHANGED
@@ -7,12 +7,12 @@ import hyperpocket.repository as repository
7
7
 
8
8
 
9
9
  @click.command()
10
- @click.argument('url', type=str)
11
- @click.option("--lockfile", envvar='PATHS', type=click.Path(exists=True))
12
- @click.option("--git-ref", type=str, default='HEAD')
10
+ @click.argument("url", type=str)
11
+ @click.option("--lockfile", envvar="PATHS", type=click.Path(exists=True))
12
+ @click.option("--git-ref", type=str, default="HEAD")
13
13
  def pull(url: str, lockfile: Optional[pathlib.Path], git_ref: str):
14
14
  if not lockfile:
15
- lockfile = pathlib.Path.cwd() / 'pocket.lock'
15
+ lockfile = pathlib.Path.cwd() / "pocket.lock"
16
16
  if not lockfile.exists():
17
17
  lockfile.touch()
18
- repository.pull(repository.Lockfile(path=lockfile), url, git_ref)
18
+ repository.pull(repository.Lockfile(path=lockfile), url, git_ref)
@@ -1,9 +1,4 @@
1
- from hyperpocket.config.settings import config as _config
2
- from hyperpocket.config.settings import settings as _settings
3
- from hyperpocket.config.logger import pocket_logger as _pocket_logger
1
+ from hyperpocket.config.logger import pocket_logger
2
+ from hyperpocket.config.settings import config
4
3
 
5
- config = _config
6
- secret = _settings
7
- pocket_logger = _pocket_logger
8
-
9
- __all__ = ["config", "secret", "pocket_logger"]
4
+ __all__ = ["config", "pocket_logger"]
@@ -20,11 +20,13 @@ class GoogleAuthConfig(BaseAuthConfig):
20
20
  class GithubAuthConfig(BaseAuthConfig):
21
21
  client_id: str
22
22
  client_secret: str
23
-
23
+
24
+
24
25
  class CalendlyAuthConfig(BaseAuthConfig):
25
26
  client_id: str
26
27
  client_secret: str
27
28
 
29
+
28
30
  class AuthConfig(BaseModel):
29
31
  slack: Optional[SlackAuthConfig] = None
30
32
  google: Optional[GoogleAuthConfig] = None
@@ -6,14 +6,16 @@ from pathlib import Path
6
6
  import hyperpocket
7
7
  from hyperpocket.config.settings import config
8
8
 
9
+
9
10
  class ColorFormatter(logging.Formatter):
10
11
  """Custom formatter to add colors based on log level."""
12
+
11
13
  # ANSI escape codes for text colors
12
14
  LEVEL_COLORS = {
13
- logging.DEBUG: "\033[36m", # Cyan
14
- logging.INFO: "\033[32m", # Green
15
- logging.WARNING: "\033[33m", # Yellow
16
- logging.ERROR: "\033[31m", # Red
15
+ logging.DEBUG: "\033[36m", # Cyan
16
+ logging.INFO: "\033[32m", # Green
17
+ logging.WARNING: "\033[33m", # Yellow
18
+ logging.ERROR: "\033[31m", # Red
17
19
  logging.CRITICAL: "\033[35m", # Magenta
18
20
  }
19
21
  RESET = "\033[0m"
@@ -24,7 +26,6 @@ class ColorFormatter(logging.Formatter):
24
26
  return f"{log_color}{message}{self.RESET}"
25
27
 
26
28
 
27
-
28
29
  def get_logger():
29
30
  # init log file
30
31
  package_path = Path(os.path.dirname(hyperpocket.__file__))
@@ -39,26 +40,28 @@ def get_logger():
39
40
  # set log level
40
41
  log_level = logging.INFO
41
42
  logger = logging.getLogger("pocket_logger")
42
- if config.log_level.lower() == "debug":
43
+ if config().log_level.lower() == "debug":
43
44
  log_level = logging.DEBUG
44
- elif config.log_level.lower() == "info":
45
+ elif config().log_level.lower() == "info":
45
46
  log_level = logging.INFO
46
- elif config.log_level.lower() == "warning":
47
+ elif config().log_level.lower() == "warning":
47
48
  log_level = logging.WARNING
48
- elif config.log_level.lower() == "error":
49
+ elif config().log_level.lower() == "error":
49
50
  log_level = logging.ERROR
50
- elif config.log_level.lower() == "critical":
51
+ elif config().log_level.lower() == "critical":
51
52
  log_level = logging.CRITICAL
52
- elif config.log_level.lower() == "fatal":
53
+ elif config().log_level.lower() == "fatal":
53
54
  log_level = logging.FATAL
54
55
 
55
56
  # set formatter
56
57
  logger.setLevel(log_level)
57
- color_formatter = ColorFormatter("[%(asctime)s] [%(levelname)s] [%(processName)s(%(process)d):%(threadName)s(%(thread)d)] [%(name)s] %(message)s",
58
- datefmt="%Y-%m-%d %H:%M:%S")
58
+ color_formatter = ColorFormatter(
59
+ "[%(asctime)s] [%(levelname)s] [%(processName)s(%(process)d):%(threadName)s(%(thread)d)] [%(name)s] %(message)s",
60
+ datefmt="%Y-%m-%d %H:%M:%S",
61
+ )
59
62
  formatter = logging.Formatter(
60
63
  "[%(asctime)s] [%(levelname)s] [%(processName)s(%(process)d):%(threadName)s(%(thread)d)] [%(name)s] %(message)s",
61
- datefmt="%Y-%m-%d %H:%M:%S"
64
+ datefmt="%Y-%m-%d %H:%M:%S",
62
65
  )
63
66
 
64
67
  # add console handler
@@ -69,7 +72,9 @@ def get_logger():
69
72
 
70
73
  # add rotating file handler
71
74
  file_handler = RotatingFileHandler(
72
- log_file, maxBytes=5 * 1024 * 1024, backupCount=100 # 파일 크기 5MB, 백업 파일 3개
75
+ log_file,
76
+ maxBytes=5 * 1024 * 1024,
77
+ backupCount=100, # 파일 크기 5MB, 백업 파일 3개
73
78
  )
74
79
  file_handler.setLevel(logging.DEBUG) # 파일 출력 레벨 설정
75
80
  file_handler.setFormatter(formatter)
@@ -24,12 +24,14 @@ class SessionConfigRedis(BaseModel):
24
24
 
25
25
  class SessionConfig(BaseModel):
26
26
  session_type: SessionType
27
- in_memory: Optional[SessionConfigInMemory] = Field(default_factory=SessionConfigInMemory)
27
+ in_memory: Optional[SessionConfigInMemory] = Field(
28
+ default_factory=SessionConfigInMemory
29
+ )
28
30
  redis: Optional[SessionConfigRedis] = Field(default_factory=SessionConfigRedis)
29
31
 
30
32
 
31
33
  DefaultSessionConfig = SessionConfig(
32
34
  session_type=SessionType.IN_MEMORY,
33
35
  in_memory=SessionConfigInMemory(),
34
- redis=SessionConfigRedis()
36
+ redis=SessionConfigRedis(),
35
37
  )
@@ -43,7 +43,7 @@ class Config(BaseModel):
43
43
  public_server_protocol: str = "https"
44
44
  public_server_port: int = 8001
45
45
  callback_url_rewrite_prefix: str = "proxy" # should not start with a slash
46
- log_level: str = "INFO"
46
+ log_level: str = "info"
47
47
  auth: AuthConfig = DefaultAuthConfig
48
48
  session: SessionConfig = DefaultSessionConfig
49
49
  tool_vars: dict[str, str] = Field(default_factory=dict)
@@ -61,4 +61,21 @@ class Config(BaseModel):
61
61
  return f"{self.public_server_protocol}://{self.public_hostname}:{self.public_server_port}"
62
62
 
63
63
 
64
- config: Config = Config.model_validate({k.lower(): v for k, v in settings.items()})
64
+ def _dynaconf_to_config(s) -> dict:
65
+ values = dict()
66
+ for k, v in s.items():
67
+ if getattr(v, "items", None) is not None:
68
+ values[str(k).lower()] = _dynaconf_to_config(v)
69
+ else:
70
+ values[str(k).lower()] = v
71
+ return values
72
+
73
+
74
+ _config = None
75
+
76
+
77
+ def config() -> Config:
78
+ global _config
79
+ if _config is None:
80
+ _config = Config.model_validate(_dynaconf_to_config(settings))
81
+ return _config
@@ -3,5 +3,5 @@ from hyperpocket.futures.futurestore import FutureStore as _FutureStore
3
3
  FutureStore = _FutureStore()
4
4
 
5
5
  __all__ = [
6
- 'FutureStore',
6
+ "FutureStore",
7
7
  ]
@@ -22,7 +22,8 @@ class FutureStore(object):
22
22
  def create_future(self, uid: str, data: dict = None) -> FutureData:
23
23
  if future := self.get_future(uid) is not None:
24
24
  pocket_logger.info(
25
- f"the future already exists. the existing future is returned. uid: {uid}")
25
+ f"the future already exists. the existing future is returned. uid: {uid}"
26
+ )
26
27
  return future
27
28
 
28
29
  loop = asyncio.get_running_loop()
@@ -39,7 +40,7 @@ class FutureStore(object):
39
40
  def resolve_future(self, uid: str, value: Any):
40
41
  future_data = self.futures.get(uid)
41
42
  if not future_data:
42
- raise ValueError(f'Future not found for uid={uid}')
43
+ raise ValueError(f"Future not found for uid={uid}")
43
44
  if not future_data.future.done():
44
45
  future_data.future.set_result(value)
45
46