ZTWHHH commited on
Commit
a3cb138
·
verified ·
1 Parent(s): 42dd1c8

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/__init__.cpython-310.pyc +0 -0
  3. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/__main__.cpython-310.pyc +0 -0
  4. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/_subprocess.cpython-310.pyc +0 -0
  5. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/_types.cpython-310.pyc +0 -0
  6. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/config.cpython-310.pyc +0 -0
  7. deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/server.cpython-310.pyc +0 -0
  8. deepseek/lib/python3.10/site-packages/uvicorn/lifespan/__init__.py +0 -0
  9. deepseek/lib/python3.10/site-packages/uvicorn/loops/__pycache__/__init__.cpython-310.pyc +0 -0
  10. deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/__init__.cpython-310.pyc +0 -0
  11. deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/asgi2.cpython-310.pyc +0 -0
  12. deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/message_logger.cpython-310.pyc +0 -0
  13. deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/wsgi.cpython-310.pyc +0 -0
  14. deepseek/lib/python3.10/site-packages/uvicorn/middleware/asgi2.py +15 -0
  15. deepseek/lib/python3.10/site-packages/uvicorn/middleware/message_logger.py +87 -0
  16. deepseek/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py +142 -0
  17. deepseek/lib/python3.10/site-packages/uvicorn/protocols/__pycache__/__init__.cpython-310.pyc +0 -0
  18. deepseek/lib/python3.10/site-packages/uvicorn/protocols/__pycache__/utils.cpython-310.pyc +0 -0
  19. deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__init__.py +0 -0
  20. deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/__init__.cpython-310.pyc +0 -0
  21. deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/auto.cpython-310.pyc +0 -0
  22. deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/flow_control.cpython-310.pyc +0 -0
  23. deepseek/lib/python3.10/site-packages/uvicorn/protocols/websockets/__pycache__/auto.cpython-310.pyc +0 -0
  24. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__init__.py +16 -0
  25. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/__init__.cpython-310.pyc +0 -0
  26. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/multiprocess.cpython-310.pyc +0 -0
  27. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/statreload.cpython-310.pyc +0 -0
  28. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/watchfilesreload.cpython-310.pyc +0 -0
  29. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/basereload.py +122 -0
  30. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/multiprocess.py +222 -0
  31. deepseek/lib/python3.10/site-packages/uvicorn/supervisors/statreload.py +53 -0
  32. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/cache_utils.cpython-310.pyc +0 -0
  33. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/convert_tf_hub_seq_to_seq_bert_to_pytorch.cpython-310.pyc +0 -0
  34. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/dependency_versions_table.cpython-310.pyc +0 -0
  35. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/generation_utils.cpython-310.pyc +0 -0
  36. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/image_processing_utils.cpython-310.pyc +0 -0
  37. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/modeling_flax_utils.cpython-310.pyc +0 -0
  38. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/modeling_tf_outputs.cpython-310.pyc +0 -0
  39. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/optimization_tf.cpython-310.pyc +0 -0
  40. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_callback.cpython-310.pyc +0 -0
  41. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_pt_utils.cpython-310.pyc +0 -0
  42. deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_seq2seq.cpython-310.pyc +0 -0
  43. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__init__.py +27 -0
  44. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/__init__.cpython-310.pyc +0 -0
  45. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/add_new_model.cpython-310.pyc +0 -0
  46. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/add_new_model_like.cpython-310.pyc +0 -0
  47. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/convert.cpython-310.pyc +0 -0
  48. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/download.cpython-310.pyc +0 -0
  49. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/env.cpython-310.pyc +0 -0
  50. deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/lfs.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -673,3 +673,4 @@ deepseekvl2/lib/python3.10/site-packages/pillow.libs/libopenjp2-ca16f087.so.2.5.
673
  deepseek/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__pycache__/__init__.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
674
  deepseekvl2/lib/python3.10/site-packages/triton/third_party/cuda/lib/libdevice.10.bc filter=lfs diff=lfs merge=lfs -text
675
  evalkit_tf437/lib/python3.10/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
673
  deepseek/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__pycache__/__init__.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
674
  deepseekvl2/lib/python3.10/site-packages/triton/third_party/cuda/lib/libdevice.10.bc filter=lfs diff=lfs merge=lfs -text
675
  evalkit_tf437/lib/python3.10/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
676
+ deepseekvl2/lib/python3.10/site-packages/transformers/models/seamless_m4t_v2/__pycache__/modeling_seamless_m4t_v2.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (346 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/__main__.cpython-310.pyc ADDED
Binary file (232 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/_subprocess.cpython-310.pyc ADDED
Binary file (2.39 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/_types.cpython-310.pyc ADDED
Binary file (9.09 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/config.cpython-310.pyc ADDED
Binary file (14.5 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/__pycache__/server.cpython-310.pyc ADDED
Binary file (8.95 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/lifespan/__init__.py ADDED
File without changes
deepseek/lib/python3.10/site-packages/uvicorn/loops/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (167 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (172 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/asgi2.cpython-310.pyc ADDED
Binary file (893 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/message_logger.cpython-310.pyc ADDED
Binary file (3 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/middleware/__pycache__/wsgi.cpython-310.pyc ADDED
Binary file (6.01 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/middleware/asgi2.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from uvicorn._types import (
2
+ ASGI2Application,
3
+ ASGIReceiveCallable,
4
+ ASGISendCallable,
5
+ Scope,
6
+ )
7
+
8
+
9
+ class ASGI2Middleware:
10
+ def __init__(self, app: "ASGI2Application"):
11
+ self.app = app
12
+
13
+ async def __call__(self, scope: "Scope", receive: "ASGIReceiveCallable", send: "ASGISendCallable") -> None:
14
+ instance = self.app(scope)
15
+ await instance(receive, send)
deepseek/lib/python3.10/site-packages/uvicorn/middleware/message_logger.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from typing import Any
3
+
4
+ from uvicorn._types import (
5
+ ASGI3Application,
6
+ ASGIReceiveCallable,
7
+ ASGIReceiveEvent,
8
+ ASGISendCallable,
9
+ ASGISendEvent,
10
+ WWWScope,
11
+ )
12
+ from uvicorn.logging import TRACE_LOG_LEVEL
13
+
14
+ PLACEHOLDER_FORMAT = {
15
+ "body": "<{length} bytes>",
16
+ "bytes": "<{length} bytes>",
17
+ "text": "<{length} chars>",
18
+ "headers": "<...>",
19
+ }
20
+
21
+
22
+ def message_with_placeholders(message: Any) -> Any:
23
+ """
24
+ Return an ASGI message, with any body-type content omitted and replaced
25
+ with a placeholder.
26
+ """
27
+ new_message = message.copy()
28
+ for attr in PLACEHOLDER_FORMAT.keys():
29
+ if message.get(attr) is not None:
30
+ content = message[attr]
31
+ placeholder = PLACEHOLDER_FORMAT[attr].format(length=len(content))
32
+ new_message[attr] = placeholder
33
+ return new_message
34
+
35
+
36
+ class MessageLoggerMiddleware:
37
+ def __init__(self, app: "ASGI3Application"):
38
+ self.task_counter = 0
39
+ self.app = app
40
+ self.logger = logging.getLogger("uvicorn.asgi")
41
+
42
+ def trace(message: Any, *args: Any, **kwargs: Any) -> None:
43
+ self.logger.log(TRACE_LOG_LEVEL, message, *args, **kwargs)
44
+
45
+ self.logger.trace = trace # type: ignore
46
+
47
+ async def __call__(
48
+ self,
49
+ scope: "WWWScope",
50
+ receive: "ASGIReceiveCallable",
51
+ send: "ASGISendCallable",
52
+ ) -> None:
53
+ self.task_counter += 1
54
+
55
+ task_counter = self.task_counter
56
+ client = scope.get("client")
57
+ prefix = "%s:%d - ASGI" % (client[0], client[1]) if client else "ASGI"
58
+
59
+ async def inner_receive() -> "ASGIReceiveEvent":
60
+ message = await receive()
61
+ logged_message = message_with_placeholders(message)
62
+ log_text = "%s [%d] Receive %s"
63
+ self.logger.trace( # type: ignore
64
+ log_text, prefix, task_counter, logged_message
65
+ )
66
+ return message
67
+
68
+ async def inner_send(message: "ASGISendEvent") -> None:
69
+ logged_message = message_with_placeholders(message)
70
+ log_text = "%s [%d] Send %s"
71
+ self.logger.trace( # type: ignore
72
+ log_text, prefix, task_counter, logged_message
73
+ )
74
+ await send(message)
75
+
76
+ logged_scope = message_with_placeholders(scope)
77
+ log_text = "%s [%d] Started scope=%s"
78
+ self.logger.trace(log_text, prefix, task_counter, logged_scope) # type: ignore
79
+ try:
80
+ await self.app(scope, inner_receive, inner_send)
81
+ except BaseException as exc:
82
+ log_text = "%s [%d] Raised exception"
83
+ self.logger.trace(log_text, prefix, task_counter) # type: ignore
84
+ raise exc from None
85
+ else:
86
+ log_text = "%s [%d] Completed"
87
+ self.logger.trace(log_text, prefix, task_counter) # type: ignore
deepseek/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import ipaddress
4
+
5
+ from uvicorn._types import ASGI3Application, ASGIReceiveCallable, ASGISendCallable, Scope
6
+
7
+
8
+ class ProxyHeadersMiddleware:
9
+ """Middleware for handling known proxy headers
10
+
11
+ This middleware can be used when a known proxy is fronting the application,
12
+ and is trusted to be properly setting the `X-Forwarded-Proto` and
13
+ `X-Forwarded-For` headers with the connecting client information.
14
+
15
+ Modifies the `client` and `scheme` information so that they reference
16
+ the connecting client, rather that the connecting proxy.
17
+
18
+ References:
19
+ - <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers#Proxies>
20
+ - <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For>
21
+ """
22
+
23
+ def __init__(self, app: ASGI3Application, trusted_hosts: list[str] | str = "127.0.0.1") -> None:
24
+ self.app = app
25
+ self.trusted_hosts = _TrustedHosts(trusted_hosts)
26
+
27
+ async def __call__(self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
28
+ if scope["type"] == "lifespan":
29
+ return await self.app(scope, receive, send)
30
+
31
+ client_addr = scope.get("client")
32
+ client_host = client_addr[0] if client_addr else None
33
+
34
+ if client_host in self.trusted_hosts:
35
+ headers = dict(scope["headers"])
36
+
37
+ if b"x-forwarded-proto" in headers:
38
+ x_forwarded_proto = headers[b"x-forwarded-proto"].decode("latin1").strip()
39
+
40
+ if x_forwarded_proto in {"http", "https", "ws", "wss"}:
41
+ if scope["type"] == "websocket":
42
+ scope["scheme"] = x_forwarded_proto.replace("http", "ws")
43
+ else:
44
+ scope["scheme"] = x_forwarded_proto
45
+
46
+ if b"x-forwarded-for" in headers:
47
+ x_forwarded_for = headers[b"x-forwarded-for"].decode("latin1")
48
+ host = self.trusted_hosts.get_trusted_client_host(x_forwarded_for)
49
+
50
+ if host:
51
+ # If the x-forwarded-for header is empty then host is an empty string.
52
+ # Only set the client if we actually got something usable.
53
+ # See: https://github.com/encode/uvicorn/issues/1068
54
+
55
+ # We've lost the connecting client's port information by now,
56
+ # so only include the host.
57
+ port = 0
58
+ scope["client"] = (host, port)
59
+
60
+ return await self.app(scope, receive, send)
61
+
62
+
63
+ def _parse_raw_hosts(value: str) -> list[str]:
64
+ return [item.strip() for item in value.split(",")]
65
+
66
+
67
+ class _TrustedHosts:
68
+ """Container for trusted hosts and networks"""
69
+
70
+ def __init__(self, trusted_hosts: list[str] | str) -> None:
71
+ self.always_trust: bool = trusted_hosts in ("*", ["*"])
72
+
73
+ self.trusted_literals: set[str] = set()
74
+ self.trusted_hosts: set[ipaddress.IPv4Address | ipaddress.IPv6Address] = set()
75
+ self.trusted_networks: set[ipaddress.IPv4Network | ipaddress.IPv6Network] = set()
76
+
77
+ # Notes:
78
+ # - We separate hosts from literals as there are many ways to write
79
+ # an IPv6 Address so we need to compare by object.
80
+ # - We don't convert IP Address to single host networks (e.g. /32 / 128) as
81
+ # it more efficient to do an address lookup in a set than check for
82
+ # membership in each network.
83
+ # - We still allow literals as it might be possible that we receive a
84
+ # something that isn't an IP Address e.g. a unix socket.
85
+
86
+ if not self.always_trust:
87
+ if isinstance(trusted_hosts, str):
88
+ trusted_hosts = _parse_raw_hosts(trusted_hosts)
89
+
90
+ for host in trusted_hosts:
91
+ # Note: because we always convert invalid IP types to literals it
92
+ # is not possible for the user to know they provided a malformed IP
93
+ # type - this may lead to unexpected / difficult to debug behaviour.
94
+
95
+ if "/" in host:
96
+ # Looks like a network
97
+ try:
98
+ self.trusted_networks.add(ipaddress.ip_network(host))
99
+ except ValueError:
100
+ # Was not a valid IP Network
101
+ self.trusted_literals.add(host)
102
+ else:
103
+ try:
104
+ self.trusted_hosts.add(ipaddress.ip_address(host))
105
+ except ValueError:
106
+ # Was not a valid IP Address
107
+ self.trusted_literals.add(host)
108
+
109
+ def __contains__(self, host: str | None) -> bool:
110
+ if self.always_trust:
111
+ return True
112
+
113
+ if not host:
114
+ return False
115
+
116
+ try:
117
+ ip = ipaddress.ip_address(host)
118
+ if ip in self.trusted_hosts:
119
+ return True
120
+ return any(ip in net for net in self.trusted_networks)
121
+
122
+ except ValueError:
123
+ return host in self.trusted_literals
124
+
125
+ def get_trusted_client_host(self, x_forwarded_for: str) -> str:
126
+ """Extract the client host from x_forwarded_for header
127
+
128
+ In general this is the first "untrusted" host in the forwarded for list.
129
+ """
130
+ x_forwarded_for_hosts = _parse_raw_hosts(x_forwarded_for)
131
+
132
+ if self.always_trust:
133
+ return x_forwarded_for_hosts[0]
134
+
135
+ # Note: each proxy appends to the header list so check it in reverse order
136
+ for host in reversed(x_forwarded_for_hosts):
137
+ if host not in self:
138
+ return host
139
+
140
+ # All hosts are trusted meaning that the client was also a trusted proxy
141
+ # See https://github.com/encode/uvicorn/issues/1068#issuecomment-855371576
142
+ return x_forwarded_for_hosts[0]
deepseek/lib/python3.10/site-packages/uvicorn/protocols/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (171 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/protocols/__pycache__/utils.cpython-310.pyc ADDED
Binary file (1.96 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__init__.py ADDED
File without changes
deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (176 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/auto.cpython-310.pyc ADDED
Binary file (537 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/protocols/http/__pycache__/flow_control.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/protocols/websockets/__pycache__/auto.cpython-310.pyc ADDED
Binary file (666 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__init__.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from uvicorn.supervisors.basereload import BaseReload
6
+ from uvicorn.supervisors.multiprocess import Multiprocess
7
+
8
+ if TYPE_CHECKING:
9
+ ChangeReload: type[BaseReload]
10
+ else:
11
+ try:
12
+ from uvicorn.supervisors.watchfilesreload import WatchFilesReload as ChangeReload
13
+ except ImportError: # pragma: no cover
14
+ from uvicorn.supervisors.statreload import StatReload as ChangeReload
15
+
16
+ __all__ = ["Multiprocess", "ChangeReload"]
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (680 Bytes). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/multiprocess.cpython-310.pyc ADDED
Binary file (7.83 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/statreload.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/__pycache__/watchfilesreload.cpython-310.pyc ADDED
Binary file (3.23 kB). View file
 
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/basereload.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import os
5
+ import signal
6
+ import sys
7
+ import threading
8
+ from collections.abc import Iterator
9
+ from pathlib import Path
10
+ from socket import socket
11
+ from types import FrameType
12
+ from typing import Callable
13
+
14
+ import click
15
+
16
+ from uvicorn._subprocess import get_subprocess
17
+ from uvicorn.config import Config
18
+
19
+ HANDLED_SIGNALS = (
20
+ signal.SIGINT, # Unix signal 2. Sent by Ctrl+C.
21
+ signal.SIGTERM, # Unix signal 15. Sent by `kill <pid>`.
22
+ )
23
+
24
+ logger = logging.getLogger("uvicorn.error")
25
+
26
+
27
+ class BaseReload:
28
+ def __init__(
29
+ self,
30
+ config: Config,
31
+ target: Callable[[list[socket] | None], None],
32
+ sockets: list[socket],
33
+ ) -> None:
34
+ self.config = config
35
+ self.target = target
36
+ self.sockets = sockets
37
+ self.should_exit = threading.Event()
38
+ self.pid = os.getpid()
39
+ self.is_restarting = False
40
+ self.reloader_name: str | None = None
41
+
42
+ def signal_handler(self, sig: int, frame: FrameType | None) -> None: # pragma: full coverage
43
+ """
44
+ A signal handler that is registered with the parent process.
45
+ """
46
+ if sys.platform == "win32" and self.is_restarting:
47
+ self.is_restarting = False
48
+ else:
49
+ self.should_exit.set()
50
+
51
+ def run(self) -> None:
52
+ self.startup()
53
+ for changes in self:
54
+ if changes:
55
+ logger.warning(
56
+ "%s detected changes in %s. Reloading...",
57
+ self.reloader_name,
58
+ ", ".join(map(_display_path, changes)),
59
+ )
60
+ self.restart()
61
+
62
+ self.shutdown()
63
+
64
+ def pause(self) -> None:
65
+ if self.should_exit.wait(self.config.reload_delay):
66
+ raise StopIteration()
67
+
68
+ def __iter__(self) -> Iterator[list[Path] | None]:
69
+ return self
70
+
71
+ def __next__(self) -> list[Path] | None:
72
+ return self.should_restart()
73
+
74
+ def startup(self) -> None:
75
+ message = f"Started reloader process [{self.pid}] using {self.reloader_name}"
76
+ color_message = "Started reloader process [{}] using {}".format(
77
+ click.style(str(self.pid), fg="cyan", bold=True),
78
+ click.style(str(self.reloader_name), fg="cyan", bold=True),
79
+ )
80
+ logger.info(message, extra={"color_message": color_message})
81
+
82
+ for sig in HANDLED_SIGNALS:
83
+ signal.signal(sig, self.signal_handler)
84
+
85
+ self.process = get_subprocess(config=self.config, target=self.target, sockets=self.sockets)
86
+ self.process.start()
87
+
88
+ def restart(self) -> None:
89
+ if sys.platform == "win32": # pragma: py-not-win32
90
+ self.is_restarting = True
91
+ assert self.process.pid is not None
92
+ os.kill(self.process.pid, signal.CTRL_C_EVENT)
93
+ else: # pragma: py-win32
94
+ self.process.terminate()
95
+ self.process.join()
96
+
97
+ self.process = get_subprocess(config=self.config, target=self.target, sockets=self.sockets)
98
+ self.process.start()
99
+
100
+ def shutdown(self) -> None:
101
+ if sys.platform == "win32":
102
+ self.should_exit.set() # pragma: py-not-win32
103
+ else:
104
+ self.process.terminate() # pragma: py-win32
105
+ self.process.join()
106
+
107
+ for sock in self.sockets:
108
+ sock.close()
109
+
110
+ message = f"Stopping reloader process [{str(self.pid)}]"
111
+ color_message = "Stopping reloader process [{}]".format(click.style(str(self.pid), fg="cyan", bold=True))
112
+ logger.info(message, extra={"color_message": color_message})
113
+
114
+ def should_restart(self) -> list[Path] | None:
115
+ raise NotImplementedError("Reload strategies should override should_restart()")
116
+
117
+
118
+ def _display_path(path: Path) -> str:
119
+ try:
120
+ return f"'{path.relative_to(Path.cwd())}'"
121
+ except ValueError:
122
+ return f"'{path}'"
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/multiprocess.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import os
5
+ import signal
6
+ import threading
7
+ from multiprocessing import Pipe
8
+ from socket import socket
9
+ from typing import Any, Callable
10
+
11
+ import click
12
+
13
+ from uvicorn._subprocess import get_subprocess
14
+ from uvicorn.config import Config
15
+
16
+ SIGNALS = {
17
+ getattr(signal, f"SIG{x}"): x
18
+ for x in "INT TERM BREAK HUP QUIT TTIN TTOU USR1 USR2 WINCH".split()
19
+ if hasattr(signal, f"SIG{x}")
20
+ }
21
+
22
+ logger = logging.getLogger("uvicorn.error")
23
+
24
+
25
+ class Process:
26
+ def __init__(
27
+ self,
28
+ config: Config,
29
+ target: Callable[[list[socket] | None], None],
30
+ sockets: list[socket],
31
+ ) -> None:
32
+ self.real_target = target
33
+
34
+ self.parent_conn, self.child_conn = Pipe()
35
+ self.process = get_subprocess(config, self.target, sockets)
36
+
37
+ def ping(self, timeout: float = 5) -> bool:
38
+ self.parent_conn.send(b"ping")
39
+ if self.parent_conn.poll(timeout):
40
+ self.parent_conn.recv()
41
+ return True
42
+ return False
43
+
44
+ def pong(self) -> None:
45
+ self.child_conn.recv()
46
+ self.child_conn.send(b"pong")
47
+
48
+ def always_pong(self) -> None:
49
+ while True:
50
+ self.pong()
51
+
52
+ def target(self, sockets: list[socket] | None = None) -> Any: # pragma: no cover
53
+ if os.name == "nt": # pragma: py-not-win32
54
+ # Windows doesn't support SIGTERM, so we use SIGBREAK instead.
55
+ # And then we raise SIGTERM when SIGBREAK is received.
56
+ # https://learn.microsoft.com/zh-cn/cpp/c-runtime-library/reference/signal?view=msvc-170
57
+ signal.signal(
58
+ signal.SIGBREAK, # type: ignore[attr-defined]
59
+ lambda sig, frame: signal.raise_signal(signal.SIGTERM),
60
+ )
61
+
62
+ threading.Thread(target=self.always_pong, daemon=True).start()
63
+ return self.real_target(sockets)
64
+
65
+ def is_alive(self, timeout: float = 5) -> bool:
66
+ if not self.process.is_alive():
67
+ return False # pragma: full coverage
68
+
69
+ return self.ping(timeout)
70
+
71
+ def start(self) -> None:
72
+ self.process.start()
73
+
74
+ def terminate(self) -> None:
75
+ if self.process.exitcode is None: # Process is still running
76
+ assert self.process.pid is not None
77
+ if os.name == "nt": # pragma: py-not-win32
78
+ # Windows doesn't support SIGTERM.
79
+ # So send SIGBREAK, and then in process raise SIGTERM.
80
+ os.kill(self.process.pid, signal.CTRL_BREAK_EVENT) # type: ignore[attr-defined]
81
+ else:
82
+ os.kill(self.process.pid, signal.SIGTERM)
83
+ logger.info(f"Terminated child process [{self.process.pid}]")
84
+
85
+ self.parent_conn.close()
86
+ self.child_conn.close()
87
+
88
+ def kill(self) -> None:
89
+ # In Windows, the method will call `TerminateProcess` to kill the process.
90
+ # In Unix, the method will send SIGKILL to the process.
91
+ self.process.kill()
92
+
93
+ def join(self) -> None:
94
+ logger.info(f"Waiting for child process [{self.process.pid}]")
95
+ self.process.join()
96
+
97
+ @property
98
+ def pid(self) -> int | None:
99
+ return self.process.pid
100
+
101
+
102
+ class Multiprocess:
103
+ def __init__(
104
+ self,
105
+ config: Config,
106
+ target: Callable[[list[socket] | None], None],
107
+ sockets: list[socket],
108
+ ) -> None:
109
+ self.config = config
110
+ self.target = target
111
+ self.sockets = sockets
112
+
113
+ self.processes_num = config.workers
114
+ self.processes: list[Process] = []
115
+
116
+ self.should_exit = threading.Event()
117
+
118
+ self.signal_queue: list[int] = []
119
+ for sig in SIGNALS:
120
+ signal.signal(sig, lambda sig, frame: self.signal_queue.append(sig))
121
+
122
+ def init_processes(self) -> None:
123
+ for _ in range(self.processes_num):
124
+ process = Process(self.config, self.target, self.sockets)
125
+ process.start()
126
+ self.processes.append(process)
127
+
128
+ def terminate_all(self) -> None:
129
+ for process in self.processes:
130
+ process.terminate()
131
+
132
+ def join_all(self) -> None:
133
+ for process in self.processes:
134
+ process.join()
135
+
136
+ def restart_all(self) -> None:
137
+ for idx, process in enumerate(self.processes):
138
+ process.terminate()
139
+ process.join()
140
+ new_process = Process(self.config, self.target, self.sockets)
141
+ new_process.start()
142
+ self.processes[idx] = new_process
143
+
144
+ def run(self) -> None:
145
+ message = f"Started parent process [{os.getpid()}]"
146
+ color_message = "Started parent process [{}]".format(click.style(str(os.getpid()), fg="cyan", bold=True))
147
+ logger.info(message, extra={"color_message": color_message})
148
+
149
+ self.init_processes()
150
+
151
+ while not self.should_exit.wait(0.5):
152
+ self.handle_signals()
153
+ self.keep_subprocess_alive()
154
+
155
+ self.terminate_all()
156
+ self.join_all()
157
+
158
+ message = f"Stopping parent process [{os.getpid()}]"
159
+ color_message = "Stopping parent process [{}]".format(click.style(str(os.getpid()), fg="cyan", bold=True))
160
+ logger.info(message, extra={"color_message": color_message})
161
+
162
+ def keep_subprocess_alive(self) -> None:
163
+ if self.should_exit.is_set():
164
+ return # parent process is exiting, no need to keep subprocess alive
165
+
166
+ for idx, process in enumerate(self.processes):
167
+ if process.is_alive():
168
+ continue
169
+
170
+ process.kill() # process is hung, kill it
171
+ process.join()
172
+
173
+ if self.should_exit.is_set():
174
+ return # pragma: full coverage
175
+
176
+ logger.info(f"Child process [{process.pid}] died")
177
+ process = Process(self.config, self.target, self.sockets)
178
+ process.start()
179
+ self.processes[idx] = process
180
+
181
+ def handle_signals(self) -> None:
182
+ for sig in tuple(self.signal_queue):
183
+ self.signal_queue.remove(sig)
184
+ sig_name = SIGNALS[sig]
185
+ sig_handler = getattr(self, f"handle_{sig_name.lower()}", None)
186
+ if sig_handler is not None:
187
+ sig_handler()
188
+ else: # pragma: no cover
189
+ logger.debug(f"Received signal {sig_name}, but no handler is defined for it.")
190
+
191
+ def handle_int(self) -> None:
192
+ logger.info("Received SIGINT, exiting.")
193
+ self.should_exit.set()
194
+
195
+ def handle_term(self) -> None:
196
+ logger.info("Received SIGTERM, exiting.")
197
+ self.should_exit.set()
198
+
199
+ def handle_break(self) -> None: # pragma: py-not-win32
200
+ logger.info("Received SIGBREAK, exiting.")
201
+ self.should_exit.set()
202
+
203
+ def handle_hup(self) -> None: # pragma: py-win32
204
+ logger.info("Received SIGHUP, restarting processes.")
205
+ self.restart_all()
206
+
207
+ def handle_ttin(self) -> None: # pragma: py-win32
208
+ logger.info("Received SIGTTIN, increasing the number of processes.")
209
+ self.processes_num += 1
210
+ process = Process(self.config, self.target, self.sockets)
211
+ process.start()
212
+ self.processes.append(process)
213
+
214
+ def handle_ttou(self) -> None: # pragma: py-win32
215
+ logger.info("Received SIGTTOU, decreasing number of processes.")
216
+ if self.processes_num <= 1:
217
+ logger.info("Already reached one process, cannot decrease the number of processes anymore.")
218
+ return
219
+ self.processes_num -= 1
220
+ process = self.processes.pop()
221
+ process.terminate()
222
+ process.join()
deepseek/lib/python3.10/site-packages/uvicorn/supervisors/statreload.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ from collections.abc import Iterator
5
+ from pathlib import Path
6
+ from socket import socket
7
+ from typing import Callable
8
+
9
+ from uvicorn.config import Config
10
+ from uvicorn.supervisors.basereload import BaseReload
11
+
12
+ logger = logging.getLogger("uvicorn.error")
13
+
14
+
15
+ class StatReload(BaseReload):
16
+ def __init__(
17
+ self,
18
+ config: Config,
19
+ target: Callable[[list[socket] | None], None],
20
+ sockets: list[socket],
21
+ ) -> None:
22
+ super().__init__(config, target, sockets)
23
+ self.reloader_name = "StatReload"
24
+ self.mtimes: dict[Path, float] = {}
25
+
26
+ if config.reload_excludes or config.reload_includes:
27
+ logger.warning("--reload-include and --reload-exclude have no effect unless " "watchfiles is installed.")
28
+
29
+ def should_restart(self) -> list[Path] | None:
30
+ self.pause()
31
+
32
+ for file in self.iter_py_files():
33
+ try:
34
+ mtime = file.stat().st_mtime
35
+ except OSError: # pragma: nocover
36
+ continue
37
+
38
+ old_time = self.mtimes.get(file)
39
+ if old_time is None:
40
+ self.mtimes[file] = mtime
41
+ continue
42
+ elif mtime > old_time:
43
+ return [file]
44
+ return None
45
+
46
+ def restart(self) -> None:
47
+ self.mtimes = {}
48
+ return super().restart()
49
+
50
+ def iter_py_files(self) -> Iterator[Path]:
51
+ for reload_dir in self.config.reload_dirs:
52
+ for path in list(reload_dir.rglob("*.py")):
53
+ yield path.resolve()
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/cache_utils.cpython-310.pyc ADDED
Binary file (15.7 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/convert_tf_hub_seq_to_seq_bert_to_pytorch.cpython-310.pyc ADDED
Binary file (1.9 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/dependency_versions_table.cpython-310.pyc ADDED
Binary file (3.03 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/generation_utils.cpython-310.pyc ADDED
Binary file (637 Bytes). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/image_processing_utils.cpython-310.pyc ADDED
Binary file (27.8 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/modeling_flax_utils.cpython-310.pyc ADDED
Binary file (40.7 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/modeling_tf_outputs.cpython-310.pyc ADDED
Binary file (55.5 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/optimization_tf.cpython-310.pyc ADDED
Binary file (14.6 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_callback.cpython-310.pyc ADDED
Binary file (23.8 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_pt_utils.cpython-310.pyc ADDED
Binary file (48.1 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/__pycache__/trainer_seq2seq.cpython-310.pyc ADDED
Binary file (11 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from abc import ABC, abstractmethod
16
+ from argparse import ArgumentParser
17
+
18
+
19
+ class BaseTransformersCLICommand(ABC):
20
+ @staticmethod
21
+ @abstractmethod
22
+ def register_subcommand(parser: ArgumentParser):
23
+ raise NotImplementedError()
24
+
25
+ @abstractmethod
26
+ def run(self):
27
+ raise NotImplementedError()
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (817 Bytes). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/add_new_model.cpython-310.pyc ADDED
Binary file (7.1 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/add_new_model_like.cpython-310.pyc ADDED
Binary file (49 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/convert.cpython-310.pyc ADDED
Binary file (4.63 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/download.cpython-310.pyc ADDED
Binary file (2.02 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/env.cpython-310.pyc ADDED
Binary file (4.12 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/transformers/commands/__pycache__/lfs.cpython-310.pyc ADDED
Binary file (7.27 kB). View file