futurehouse-client 0.3.18.dev109__py3-none-any.whl → 0.3.18.dev110__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.
@@ -1,3 +1,7 @@
1
- from .context import UserContext
1
+ from .context import JOB_ID_CONTEXT_KEY, USER_JWT_CONTEXT_KEY, RequestContext
2
2
 
3
- __all__ = ["UserContext"]
3
+ __all__ = [
4
+ "JOB_ID_CONTEXT_KEY",
5
+ "USER_JWT_CONTEXT_KEY",
6
+ "RequestContext",
7
+ ]
@@ -1,16 +1,45 @@
1
- class UserContext:
2
- """A context manager for storing user information from the initial request."""
1
+ from typing import Any, ClassVar
3
2
 
4
- _user_jwt = None
3
+ USER_JWT_CONTEXT_KEY = "user_jwt"
4
+ JOB_ID_CONTEXT_KEY = "job_id"
5
+
6
+
7
+ class RequestContext:
8
+ """A context manager for storing information from the initial request."""
9
+
10
+ _context: ClassVar[dict[str, Any]] = {}
5
11
 
6
12
  @classmethod
7
- def set_user_jwt(cls, jwt: str) -> None:
8
- cls._user_jwt = jwt
13
+ def set(cls, key: str, value: Any) -> None:
14
+ """Set a context variable.
15
+
16
+ Args:
17
+ key: The context variable name
18
+ value: The value to store
19
+ """
20
+ cls._context[key] = value
9
21
 
10
22
  @classmethod
11
- def get_user_jwt(cls) -> str | None:
12
- return cls._user_jwt
23
+ def get(cls, key: str) -> Any:
24
+ """Get a context variable.
25
+
26
+ Args:
27
+ key: The context variable name
28
+ default: Default value if key doesn't exist
29
+
30
+ Returns:
31
+ The stored value or default if not found
32
+ """
33
+ return cls._context.get(key, None)
13
34
 
14
35
  @classmethod
15
- def clear_user_jwt(cls) -> None:
16
- cls._user_jwt = None
36
+ def clear(cls, key: str | None = None) -> None:
37
+ """Clear a specific context variable or all variables.
38
+
39
+ Args:
40
+ key: Specific key to clear, or None to clear all
41
+ """
42
+ if key is None:
43
+ cls._context.clear()
44
+ elif key in cls._context:
45
+ del cls._context[key]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.3.18.dev109
3
+ Version: 0.3.18.dev110
4
4
  Summary: A client for interacting with endpoints of the FutureHouse service.
5
5
  Author-email: FutureHouse technical staff <hello@futurehouse.org>
6
6
  Classifier: Operating System :: OS Independent
@@ -6,12 +6,12 @@ futurehouse_client/models/__init__.py,sha256=ta3jFLM_LsDz1rKDmx8rja8sT7WtSKoFvMg
6
6
  futurehouse_client/models/app.py,sha256=yfZ9tyw4VATVAfYrU7aTdCNPSljLEho09_nIbh8oZDY,23174
7
7
  futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
8
8
  futurehouse_client/models/rest.py,sha256=lgwkMIXz0af-49BYSkKeS7SRqvN3motqnAikDN4YGTc,789
9
- futurehouse_client/utils/__init__.py,sha256=mCp1UP3eyrWyHpFAEHgKcazKCJ5g87MxlDIZVzi-5Tk,60
10
- futurehouse_client/utils/context.py,sha256=MdYYldQfsqxnGJUDcMLkbRtKHb2srHfcMf6aR-oZh6Y,387
9
+ futurehouse_client/utils/__init__.py,sha256=Tlz5A-h2h2R8SZo7HXtNGNwDY08zCMWtE33PnSw5jjo,169
10
+ futurehouse_client/utils/context.py,sha256=QN_-Z61IQtAUOZaBDoP5F6pqvrkMxZ7y-1t7LEuF6lI,1162
11
11
  futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
12
12
  futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
13
13
  futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
14
- futurehouse_client-0.3.18.dev109.dist-info/METADATA,sha256=yeDUNer_jX0nDUAgV26q5ssYrcWmWlCpuqy6iRuSz_c,12767
15
- futurehouse_client-0.3.18.dev109.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
16
- futurehouse_client-0.3.18.dev109.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
- futurehouse_client-0.3.18.dev109.dist-info/RECORD,,
14
+ futurehouse_client-0.3.18.dev110.dist-info/METADATA,sha256=DQlgzMDU6QxiO2hvu29l1K3EDgjipG2ew6vtsfFdlF8,12767
15
+ futurehouse_client-0.3.18.dev110.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
16
+ futurehouse_client-0.3.18.dev110.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
17
+ futurehouse_client-0.3.18.dev110.dist-info/RECORD,,