ominfra 0.0.0.dev144__tar.gz → 0.0.0.dev145__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. {ominfra-0.0.0.dev144/ominfra.egg-info → ominfra-0.0.0.dev145}/PKG-INFO +3 -3
  2. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/execution.py +1 -1
  3. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/inject.py +2 -3
  4. ominfra-0.0.0.dev145/ominfra/manage/deploy/paths.py +33 -0
  5. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/main.py +2 -1
  6. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/execution.py +2 -1
  7. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/scripts/journald2aws.py +73 -53
  8. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/scripts/manage.py +77 -58
  9. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/scripts/supervisor.py +114 -94
  10. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/dispatchers.py +3 -3
  11. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/http.py +6 -6
  12. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/inject.py +12 -12
  13. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/io.py +2 -2
  14. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/spawningimpl.py +2 -2
  15. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/supervisor.py +2 -2
  16. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/types.py +2 -2
  17. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145/ominfra.egg-info}/PKG-INFO +3 -3
  18. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra.egg-info/SOURCES.txt +1 -0
  19. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra.egg-info/requires.txt +2 -2
  20. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/pyproject.toml +3 -3
  21. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/LICENSE +0 -0
  22. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/MANIFEST.in +0 -0
  23. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/README.rst +0 -0
  24. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/.manifests.json +0 -0
  25. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/__about__.py +0 -0
  26. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/__init__.py +0 -0
  27. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/__init__.py +0 -0
  28. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/__init__.py +0 -0
  29. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/__main__.py +0 -0
  30. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/auth.py +0 -0
  31. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/cli.py +0 -0
  32. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/dataclasses.py +0 -0
  33. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
  34. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
  35. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
  36. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
  37. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/main.py +0 -0
  38. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
  39. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/logs.py +0 -0
  40. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/aws/metadata.py +0 -0
  41. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/gcp/__init__.py +0 -0
  42. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/clouds/gcp/auth.py +0 -0
  43. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/cmds.py +0 -0
  44. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/configs.py +0 -0
  45. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/journald/__init__.py +0 -0
  46. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/journald/fields.py +0 -0
  47. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/journald/genmessages.py +0 -0
  48. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/journald/messages.py +0 -0
  49. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/journald/tailer.py +0 -0
  50. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/__init__.py +0 -0
  51. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/__main__.py +0 -0
  52. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/bootstrap.py +0 -0
  53. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/bootstrap_.py +0 -0
  54. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/__init__.py +0 -0
  55. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/base.py +0 -0
  56. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/marshal.py +0 -0
  57. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/commands/subprocess.py +0 -0
  58. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/config.py +0 -0
  59. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/deploy/__init__.py +0 -0
  60. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/deploy/command.py +0 -0
  61. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/deploy/inject.py +0 -0
  62. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/inject.py +0 -0
  63. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/marshal.py +0 -0
  64. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/__init__.py +0 -0
  65. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/channel.py +0 -0
  66. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/config.py +0 -0
  67. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/inject.py +0 -0
  68. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/payload.py +0 -0
  69. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/manage/remote/spawning.py +0 -0
  70. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/pyremote.py +0 -0
  71. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/scripts/__init__.py +0 -0
  72. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/ssh.py +0 -0
  73. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/LICENSE.txt +0 -0
  74. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/__init__.py +0 -0
  75. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/__main__.py +0 -0
  76. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/configs.py +0 -0
  77. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/dispatchersimpl.py +0 -0
  78. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/events.py +0 -0
  79. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/exceptions.py +0 -0
  80. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/groups.py +0 -0
  81. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/groupsimpl.py +0 -0
  82. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/main.py +0 -0
  83. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/pipes.py +0 -0
  84. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/privileges.py +0 -0
  85. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/process.py +0 -0
  86. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/processimpl.py +0 -0
  87. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/setup.py +0 -0
  88. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/setupimpl.py +0 -0
  89. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/signals.py +0 -0
  90. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/spawning.py +0 -0
  91. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/states.py +0 -0
  92. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/__init__.py +0 -0
  93. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/collections.py +0 -0
  94. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/diag.py +0 -0
  95. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/fds.py +0 -0
  96. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/fs.py +0 -0
  97. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/os.py +0 -0
  98. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/ostypes.py +0 -0
  99. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/signals.py +0 -0
  100. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/strings.py +0 -0
  101. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/supervisor/utils/users.py +0 -0
  102. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/tailscale/__init__.py +0 -0
  103. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/tailscale/api.py +0 -0
  104. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/tailscale/cli.py +0 -0
  105. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/threadworkers.py +0 -0
  106. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/tools/__init__.py +0 -0
  107. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra/tools/listresources.py +0 -0
  108. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra.egg-info/dependency_links.txt +0 -0
  109. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra.egg-info/entry_points.txt +0 -0
  110. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/ominfra.egg-info/top_level.txt +0 -0
  111. {ominfra-0.0.0.dev144 → ominfra-0.0.0.dev145}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev144
3
+ Version: 0.0.0.dev145
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev144
16
- Requires-Dist: omlish==0.0.0.dev144
15
+ Requires-Dist: omdev==0.0.0.dev145
16
+ Requires-Dist: omlish==0.0.0.dev145
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -8,7 +8,7 @@ from .base import CommandExecutor
8
8
  CommandExecutorMap = ta.NewType('CommandExecutorMap', ta.Mapping[ta.Type[Command], CommandExecutor])
9
9
 
10
10
 
11
- class CommandExecutionService(CommandExecutor):
11
+ class LocalCommandExecutor(CommandExecutor):
12
12
  def __init__(
13
13
  self,
14
14
  *,
@@ -18,8 +18,8 @@ from .base import CommandNameMap
18
18
  from .base import CommandRegistration
19
19
  from .base import CommandRegistrations
20
20
  from .base import build_command_name_map
21
- from .execution import CommandExecutionService
22
21
  from .execution import CommandExecutorMap
22
+ from .execution import LocalCommandExecutor
23
23
  from .marshal import install_command_marshaling
24
24
  from .subprocess import SubprocessCommand
25
25
  from .subprocess import SubprocessCommandExecutor
@@ -106,8 +106,7 @@ def bind_commands(
106
106
  lst.extend([
107
107
  inj.bind(provide_command_executor_map, singleton=True),
108
108
 
109
- inj.bind(CommandExecutionService, singleton=True, eager=main_config.debug),
110
- inj.bind(CommandExecutor, to_key=CommandExecutionService),
109
+ inj.bind(LocalCommandExecutor, singleton=True, eager=main_config.debug),
111
110
  ])
112
111
 
113
112
  #
@@ -0,0 +1,33 @@
1
+ # ruff: noqa: UP006 UP007
2
+ """
3
+ ~deploy
4
+ deploy.pid (flock)
5
+ /app
6
+ /<appspec> - shallow clone
7
+ /conf
8
+ /env
9
+ <appspec>.env
10
+ /nginx
11
+ <appspec>.conf
12
+ /supervisor
13
+ <appspec>.conf
14
+ /venv
15
+ /<appspec>
16
+
17
+ ?
18
+ /logs
19
+ /wrmsr--omlish--<spec>
20
+
21
+ spec = <name>--<rev>--<when>
22
+
23
+ ==
24
+
25
+ for dn in [
26
+ 'app',
27
+ 'conf',
28
+ 'conf/env',
29
+ 'conf/nginx',
30
+ 'conf/supervisor',
31
+ 'venv',
32
+ ]:
33
+ """
@@ -17,6 +17,7 @@ from .bootstrap import MainBootstrap
17
17
  from .bootstrap_ import main_bootstrap
18
18
  from .commands.base import Command
19
19
  from .commands.base import CommandExecutor
20
+ from .commands.execution import LocalCommandExecutor
20
21
  from .commands.subprocess import SubprocessCommand
21
22
  from .config import MainConfig
22
23
  from .deploy.command import DeployCommand
@@ -90,7 +91,7 @@ def _main() -> None:
90
91
  ce: CommandExecutor
91
92
 
92
93
  if args.local:
93
- ce = injector[CommandExecutor]
94
+ ce = injector[LocalCommandExecutor]
94
95
 
95
96
  else:
96
97
  tgt = RemoteSpawning.Target(
@@ -20,6 +20,7 @@ from ..commands.base import CommandException
20
20
  from ..commands.base import CommandExecutor
21
21
  from ..commands.base import CommandOutputOrException
22
22
  from ..commands.base import CommandOutputOrExceptionData
23
+ from ..commands.execution import LocalCommandExecutor
23
24
  from .channel import RemoteChannel
24
25
  from .payload import RemoteExecutionPayloadFile
25
26
  from .payload import get_remote_payload_src
@@ -52,7 +53,7 @@ def _remote_execution_main() -> None:
52
53
 
53
54
  chan.set_marshaler(injector[ObjMarshalerManager])
54
55
 
55
- ce = injector[CommandExecutor]
56
+ ce = injector[LocalCommandExecutor]
56
57
 
57
58
  while True:
58
59
  i = chan.recv_obj(Command)
@@ -2169,23 +2169,24 @@ TODO:
2169
2169
  @dc.dataclass(frozen=True)
2170
2170
  class ObjMarshalOptions:
2171
2171
  raw_bytes: bool = False
2172
+ nonstrict_dataclasses: bool = False
2172
2173
 
2173
2174
 
2174
2175
  class ObjMarshaler(abc.ABC):
2175
2176
  @abc.abstractmethod
2176
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2177
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2177
2178
  raise NotImplementedError
2178
2179
 
2179
2180
  @abc.abstractmethod
2180
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2181
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2181
2182
  raise NotImplementedError
2182
2183
 
2183
2184
 
2184
2185
  class NopObjMarshaler(ObjMarshaler):
2185
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2186
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2186
2187
  return o
2187
2188
 
2188
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2189
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2189
2190
  return o
2190
2191
 
2191
2192
 
@@ -2193,29 +2194,29 @@ class NopObjMarshaler(ObjMarshaler):
2193
2194
  class ProxyObjMarshaler(ObjMarshaler):
2194
2195
  m: ta.Optional[ObjMarshaler] = None
2195
2196
 
2196
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2197
- return check_not_none(self.m).marshal(o, opts)
2197
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2198
+ return check_not_none(self.m).marshal(o, ctx)
2198
2199
 
2199
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2200
- return check_not_none(self.m).unmarshal(o, opts)
2200
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2201
+ return check_not_none(self.m).unmarshal(o, ctx)
2201
2202
 
2202
2203
 
2203
2204
  @dc.dataclass(frozen=True)
2204
2205
  class CastObjMarshaler(ObjMarshaler):
2205
2206
  ty: type
2206
2207
 
2207
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2208
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2208
2209
  return o
2209
2210
 
2210
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2211
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2211
2212
  return self.ty(o)
2212
2213
 
2213
2214
 
2214
2215
  class DynamicObjMarshaler(ObjMarshaler):
2215
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2216
- return marshal_obj(o)
2216
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2217
+ return ctx.manager.marshal_obj(o, opts=ctx.options)
2217
2218
 
2218
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2219
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2219
2220
  return o
2220
2221
 
2221
2222
 
@@ -2223,10 +2224,10 @@ class DynamicObjMarshaler(ObjMarshaler):
2223
2224
  class Base64ObjMarshaler(ObjMarshaler):
2224
2225
  ty: type
2225
2226
 
2226
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2227
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2227
2228
  return base64.b64encode(o).decode('ascii')
2228
2229
 
2229
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2230
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2230
2231
  return self.ty(base64.b64decode(o))
2231
2232
 
2232
2233
 
@@ -2234,25 +2235,25 @@ class Base64ObjMarshaler(ObjMarshaler):
2234
2235
  class BytesSwitchedObjMarshaler(ObjMarshaler):
2235
2236
  m: ObjMarshaler
2236
2237
 
2237
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2238
- if opts.raw_bytes:
2238
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2239
+ if ctx.options.raw_bytes:
2239
2240
  return o
2240
- return self.m.marshal(o, opts)
2241
+ return self.m.marshal(o, ctx)
2241
2242
 
2242
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2243
- if opts.raw_bytes:
2243
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2244
+ if ctx.options.raw_bytes:
2244
2245
  return o
2245
- return self.m.unmarshal(o, opts)
2246
+ return self.m.unmarshal(o, ctx)
2246
2247
 
2247
2248
 
2248
2249
  @dc.dataclass(frozen=True)
2249
2250
  class EnumObjMarshaler(ObjMarshaler):
2250
2251
  ty: type
2251
2252
 
2252
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2253
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2253
2254
  return o.name
2254
2255
 
2255
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2256
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2256
2257
  return self.ty.__members__[o] # type: ignore
2257
2258
 
2258
2259
 
@@ -2260,15 +2261,15 @@ class EnumObjMarshaler(ObjMarshaler):
2260
2261
  class OptionalObjMarshaler(ObjMarshaler):
2261
2262
  item: ObjMarshaler
2262
2263
 
2263
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2264
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2264
2265
  if o is None:
2265
2266
  return None
2266
- return self.item.marshal(o, opts)
2267
+ return self.item.marshal(o, ctx)
2267
2268
 
2268
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2269
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2269
2270
  if o is None:
2270
2271
  return None
2271
- return self.item.unmarshal(o, opts)
2272
+ return self.item.unmarshal(o, ctx)
2272
2273
 
2273
2274
 
2274
2275
  @dc.dataclass(frozen=True)
@@ -2277,11 +2278,11 @@ class MappingObjMarshaler(ObjMarshaler):
2277
2278
  km: ObjMarshaler
2278
2279
  vm: ObjMarshaler
2279
2280
 
2280
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2281
- return {self.km.marshal(k, opts): self.vm.marshal(v, opts) for k, v in o.items()}
2281
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2282
+ return {self.km.marshal(k, ctx): self.vm.marshal(v, ctx) for k, v in o.items()}
2282
2283
 
2283
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2284
- return self.ty((self.km.unmarshal(k, opts), self.vm.unmarshal(v, opts)) for k, v in o.items())
2284
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2285
+ return self.ty((self.km.unmarshal(k, ctx), self.vm.unmarshal(v, ctx)) for k, v in o.items())
2285
2286
 
2286
2287
 
2287
2288
  @dc.dataclass(frozen=True)
@@ -2289,11 +2290,11 @@ class IterableObjMarshaler(ObjMarshaler):
2289
2290
  ty: type
2290
2291
  item: ObjMarshaler
2291
2292
 
2292
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2293
- return [self.item.marshal(e, opts) for e in o]
2293
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2294
+ return [self.item.marshal(e, ctx) for e in o]
2294
2295
 
2295
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2296
- return self.ty(self.item.unmarshal(e, opts) for e in o)
2296
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2297
+ return self.ty(self.item.unmarshal(e, ctx) for e in o)
2297
2298
 
2298
2299
 
2299
2300
  @dc.dataclass(frozen=True)
@@ -2302,11 +2303,18 @@ class DataclassObjMarshaler(ObjMarshaler):
2302
2303
  fs: ta.Mapping[str, ObjMarshaler]
2303
2304
  nonstrict: bool = False
2304
2305
 
2305
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2306
- return {k: m.marshal(getattr(o, k), opts) for k, m in self.fs.items()}
2306
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2307
+ return {
2308
+ k: m.marshal(getattr(o, k), ctx)
2309
+ for k, m in self.fs.items()
2310
+ }
2307
2311
 
2308
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2309
- return self.ty(**{k: self.fs[k].unmarshal(v, opts) for k, v in o.items() if not self.nonstrict or k in self.fs})
2312
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2313
+ return self.ty(**{
2314
+ k: self.fs[k].unmarshal(v, ctx)
2315
+ for k, v in o.items()
2316
+ if not (self.nonstrict or ctx.options.nonstrict_dataclasses) or k in self.fs
2317
+ })
2310
2318
 
2311
2319
 
2312
2320
  @dc.dataclass(frozen=True)
@@ -2326,50 +2334,50 @@ class PolymorphicObjMarshaler(ObjMarshaler):
2326
2334
  {i.tag: i for i in impls},
2327
2335
  )
2328
2336
 
2329
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2337
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2330
2338
  impl = self.impls_by_ty[type(o)]
2331
- return {impl.tag: impl.m.marshal(o, opts)}
2339
+ return {impl.tag: impl.m.marshal(o, ctx)}
2332
2340
 
2333
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2341
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2334
2342
  [(t, v)] = o.items()
2335
2343
  impl = self.impls_by_tag[t]
2336
- return impl.m.unmarshal(v, opts)
2344
+ return impl.m.unmarshal(v, ctx)
2337
2345
 
2338
2346
 
2339
2347
  @dc.dataclass(frozen=True)
2340
2348
  class DatetimeObjMarshaler(ObjMarshaler):
2341
2349
  ty: type
2342
2350
 
2343
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2351
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2344
2352
  return o.isoformat()
2345
2353
 
2346
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2354
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2347
2355
  return self.ty.fromisoformat(o) # type: ignore
2348
2356
 
2349
2357
 
2350
2358
  class DecimalObjMarshaler(ObjMarshaler):
2351
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2359
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2352
2360
  return str(check_isinstance(o, decimal.Decimal))
2353
2361
 
2354
- def unmarshal(self, v: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2362
+ def unmarshal(self, v: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2355
2363
  return decimal.Decimal(check_isinstance(v, str))
2356
2364
 
2357
2365
 
2358
2366
  class FractionObjMarshaler(ObjMarshaler):
2359
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2367
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2360
2368
  fr = check_isinstance(o, fractions.Fraction)
2361
2369
  return [fr.numerator, fr.denominator]
2362
2370
 
2363
- def unmarshal(self, v: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2371
+ def unmarshal(self, v: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2364
2372
  num, denom = check_isinstance(v, list)
2365
2373
  return fractions.Fraction(num, denom)
2366
2374
 
2367
2375
 
2368
2376
  class UuidObjMarshaler(ObjMarshaler):
2369
- def marshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2377
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2370
2378
  return str(o)
2371
2379
 
2372
- def unmarshal(self, o: ta.Any, opts: ObjMarshalOptions) -> ta.Any:
2380
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
2373
2381
  return uuid.UUID(o)
2374
2382
 
2375
2383
 
@@ -2530,6 +2538,12 @@ class ObjMarshalerManager:
2530
2538
 
2531
2539
  #
2532
2540
 
2541
+ def _make_context(self, opts: ta.Optional[ObjMarshalOptions]) -> 'ObjMarshalContext':
2542
+ return ObjMarshalContext(
2543
+ options=opts or self._default_options,
2544
+ manager=self,
2545
+ )
2546
+
2533
2547
  def marshal_obj(
2534
2548
  self,
2535
2549
  o: ta.Any,
@@ -2537,7 +2551,7 @@ class ObjMarshalerManager:
2537
2551
  opts: ta.Optional[ObjMarshalOptions] = None,
2538
2552
  ) -> ta.Any:
2539
2553
  m = self.get_obj_marshaler(ty if ty is not None else type(o))
2540
- return m.marshal(o, opts or self._default_options)
2554
+ return m.marshal(o, self._make_context(opts))
2541
2555
 
2542
2556
  def unmarshal_obj(
2543
2557
  self,
@@ -2546,7 +2560,7 @@ class ObjMarshalerManager:
2546
2560
  opts: ta.Optional[ObjMarshalOptions] = None,
2547
2561
  ) -> T:
2548
2562
  m = self.get_obj_marshaler(ty)
2549
- return m.unmarshal(o, opts or self._default_options)
2563
+ return m.unmarshal(o, self._make_context(opts))
2550
2564
 
2551
2565
  def roundtrip_obj(
2552
2566
  self,
@@ -2561,6 +2575,12 @@ class ObjMarshalerManager:
2561
2575
  return u
2562
2576
 
2563
2577
 
2578
+ @dc.dataclass(frozen=True)
2579
+ class ObjMarshalContext:
2580
+ options: ObjMarshalOptions
2581
+ manager: ObjMarshalerManager
2582
+
2583
+
2564
2584
  ##
2565
2585
 
2566
2586