-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #727 from dlt-hub/d#/platform_connection
prototype platform connection
- Loading branch information
Showing
16 changed files
with
405 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
|
||
import atexit | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
|
||
class ManagedThreadPool: | ||
def __init__(self, max_workers: int = 1) -> None: | ||
self._max_workers = max_workers | ||
self._thread_pool: Optional[ThreadPoolExecutor] = None | ||
|
||
def _create_thread_pool(self) -> None: | ||
assert not self._thread_pool, "Thread pool already created" | ||
self._thread_pool = ThreadPoolExecutor(self._max_workers) | ||
# flush pool on exit | ||
atexit.register(self.stop) | ||
|
||
@property | ||
def thread_pool(self) -> ThreadPoolExecutor: | ||
if not self._thread_pool: | ||
self._create_thread_pool() | ||
return self._thread_pool | ||
|
||
def stop(self, wait: bool = True) -> None: | ||
if self._thread_pool: | ||
self._thread_pool.shutdown(wait=wait) | ||
self._thread_pool = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import ( | ||
Any, | ||
Callable, | ||
Dict, | ||
List, | ||
Literal, | ||
Optional, | ||
Sequence, | ||
Set, | ||
Type, | ||
TypedDict, | ||
NewType, | ||
Union, | ||
get_args, | ||
) | ||
|
||
|
||
TExecInfoNames = Literal[ | ||
"kubernetes", | ||
"docker", | ||
"codespaces", | ||
"github_actions", | ||
"airflow", | ||
"notebook", | ||
"colab", | ||
"aws_lambda", | ||
"gcp_cloud_function", | ||
] | ||
|
||
|
||
class TVersion(TypedDict): | ||
"""TypeDict representing a library version""" | ||
|
||
name: str | ||
version: str | ||
|
||
|
||
class TExecutionContext(TypedDict): | ||
"""TypeDict representing the runtime context info""" | ||
|
||
ci_run: bool | ||
python: str | ||
cpu: int | ||
exec_info: List[TExecInfoNames] | ||
library: TVersion | ||
os: TVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.