fmtr.tools 1.0.25__py3-none-any.whl → 1.0.27__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.
Potentially problematic release.
This version of fmtr.tools might be problematic. Click here for more details.
- fmtr/tools/config.py +4 -1
- fmtr/tools/logging_tools.py +13 -9
- fmtr/tools/version +1 -1
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/METADATA +6 -2
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/RECORD +9 -9
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/LICENSE +0 -0
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/WHEEL +0 -0
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/entry_points.txt +0 -0
- {fmtr.tools-1.0.25.dist-info → fmtr.tools-1.0.27.dist-info}/top_level.txt +0 -0
fmtr/tools/config.py
CHANGED
|
@@ -5,7 +5,8 @@ from fmtr.tools.config_tools import ConfigClass
|
|
|
5
5
|
|
|
6
6
|
class ToolsConfig(ConfigClass):
|
|
7
7
|
ENCODING = 'UTF-8'
|
|
8
|
-
|
|
8
|
+
ORG_NAME = 'fmtr'
|
|
9
|
+
LIBRARY_NAME = f'{ORG_NAME}.tools'
|
|
9
10
|
DATE_FILENAME_FORMAT = '%Y-%m-%d'
|
|
10
11
|
TIME_FILENAME_FORMAT = '%H-%M-%S'
|
|
11
12
|
|
|
@@ -16,3 +17,5 @@ class ToolsConfig(ConfigClass):
|
|
|
16
17
|
SERIALIZATION_INDENT = 4
|
|
17
18
|
|
|
18
19
|
FMTR_LOG_LEVEL_KEY = 'FMTR_LOG_LEVEL'
|
|
20
|
+
FMTR_OBS_API_KEY_KEY = 'FMTR_OBS_API_KEY'
|
|
21
|
+
FMTR_OBS_HOST = 'log.sv.fmtr.dev'
|
fmtr/tools/logging_tools.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
from logfire import ConsoleOptions
|
|
3
4
|
|
|
4
5
|
from fmtr.tools import environment_tools
|
|
6
|
+
from fmtr.tools.config import ToolsConfig
|
|
5
7
|
|
|
6
8
|
DEVELOPMENT = "development"
|
|
7
9
|
PRODUCTION = "production"
|
|
8
|
-
HOST_DEFAULT = "log.sv.fmtr.dev"
|
|
9
|
-
ORG_DEFAULT = "fmtr"
|
|
10
10
|
STREAM_DEFAULT = DEVELOPMENT
|
|
11
11
|
ENVIRONMENT_DEFAULT = DEVELOPMENT
|
|
12
12
|
|
|
13
13
|
LEVEL_DEFAULT = logging.DEBUG if environment_tools.IS_DEBUG else logging.INFO
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def get_logger(name, version, host=
|
|
16
|
+
def get_logger(name, version=None, host=ToolsConfig.FMTR_OBS_HOST, org=ToolsConfig.ORG_NAME, stream=STREAM_DEFAULT,
|
|
17
17
|
environment=ENVIRONMENT_DEFAULT, level=LEVEL_DEFAULT):
|
|
18
18
|
"""
|
|
19
19
|
|
|
@@ -30,20 +30,24 @@ def get_logger(name, version, host=HOST_DEFAULT, org=ORG_DEFAULT, stream=STREAM_
|
|
|
30
30
|
|
|
31
31
|
return logger
|
|
32
32
|
|
|
33
|
-
key = environment_tools.get(
|
|
34
|
-
|
|
33
|
+
key = environment_tools.get(ToolsConfig.FMTR_OBS_API_KEY_KEY)
|
|
34
|
+
url = f"https://{host}/api/{org}/v1/traces"
|
|
35
35
|
headers = f"Authorization=Basic {key},stream-name={stream}"
|
|
36
36
|
|
|
37
|
-
os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] =
|
|
37
|
+
os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = url
|
|
38
38
|
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = headers
|
|
39
39
|
os.environ["OTEL_EXPORTER_OTLP_INSECURE"] = str(False).lower()
|
|
40
40
|
|
|
41
|
+
if not version:
|
|
42
|
+
from fmtr.tools import version_tools
|
|
43
|
+
version = version_tools.read()
|
|
44
|
+
|
|
41
45
|
logfire.configure(
|
|
42
46
|
service_name=name,
|
|
43
47
|
service_version=version,
|
|
44
48
|
environment=environment,
|
|
45
|
-
send_to_logfire=False
|
|
46
|
-
|
|
49
|
+
send_to_logfire=False,
|
|
50
|
+
console=ConsoleOptions(colors='always' if environment_tools.IS_DEBUG else 'auto')
|
|
47
51
|
)
|
|
48
52
|
|
|
49
53
|
logging.getLogger(name).setLevel(level)
|
|
@@ -52,6 +56,6 @@ def get_logger(name, version, host=HOST_DEFAULT, org=ORG_DEFAULT, stream=STREAM_
|
|
|
52
56
|
return logger
|
|
53
57
|
|
|
54
58
|
|
|
55
|
-
logger = get_logger(name=
|
|
59
|
+
logger = get_logger(name=ToolsConfig.LIBRARY_NAME)
|
|
56
60
|
|
|
57
61
|
logger = get_logger()
|
fmtr/tools/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.27
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fmtr.tools
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.27
|
|
4
4
|
Summary: Collection of high-level tools to simplify everyday development tasks, with a focus on AI/ML
|
|
5
5
|
Home-page: https://github.com/fmtr/fmtr.tools
|
|
6
6
|
Author: Frontmatter
|
|
@@ -23,6 +23,7 @@ Provides-Extra: api
|
|
|
23
23
|
Requires-Dist: fastapi ; extra == 'api'
|
|
24
24
|
Requires-Dist: logfire ; extra == 'api'
|
|
25
25
|
Requires-Dist: pydantic ; extra == 'api'
|
|
26
|
+
Requires-Dist: semver ; extra == 'api'
|
|
26
27
|
Requires-Dist: uvicorn ; extra == 'api'
|
|
27
28
|
Provides-Extra: augmentation
|
|
28
29
|
Requires-Dist: faker ; extra == 'augmentation'
|
|
@@ -49,6 +50,7 @@ Provides-Extra: json-fix
|
|
|
49
50
|
Requires-Dist: json-repair ; extra == 'json-fix'
|
|
50
51
|
Provides-Extra: logging
|
|
51
52
|
Requires-Dist: logfire ; extra == 'logging'
|
|
53
|
+
Requires-Dist: semver ; extra == 'logging'
|
|
52
54
|
Provides-Extra: merging
|
|
53
55
|
Requires-Dist: deepmerge ; extra == 'merging'
|
|
54
56
|
Provides-Extra: metric
|
|
@@ -63,6 +65,7 @@ Requires-Dist: dask[bag] ; extra == 'parallel'
|
|
|
63
65
|
Requires-Dist: distributed ; extra == 'parallel'
|
|
64
66
|
Provides-Extra: process
|
|
65
67
|
Requires-Dist: logfire ; extra == 'process'
|
|
68
|
+
Requires-Dist: semver ; extra == 'process'
|
|
66
69
|
Provides-Extra: profiling
|
|
67
70
|
Requires-Dist: contexttimer ; extra == 'profiling'
|
|
68
71
|
Provides-Extra: semantic
|
|
@@ -246,7 +249,8 @@ The included modules, plus any extra requirements, are as follows:
|
|
|
246
249
|
- Extras: None
|
|
247
250
|
- `tools.logging`: Configures and initializes a logger using the Logfire library to log to an OpenTelemetry consumer.
|
|
248
251
|
- Extras: `logging`
|
|
249
|
-
- `tools.logger`: Prefabricated
|
|
252
|
+
- `tools.logger`: Prefabricated
|
|
253
|
+
`logger` object, suitable for most projects: service name, colour-coded, timestamped, etc.
|
|
250
254
|
- Extras: `logging`
|
|
251
255
|
- `tools.augmentation`: Data augmentation stub.
|
|
252
256
|
- Extras: `augmentation`
|
|
@@ -4,7 +4,7 @@ fmtr/tools/api_tools.py,sha256=KU_qetI7WQRZijZ0l1nCKjPcRbseMMCWj0W8n_NTJCM,2027
|
|
|
4
4
|
fmtr/tools/async_tools.py,sha256=ewz757WcveQJd-G5SVr2JDOQVbdLGecCgl-tsBGVZz4,284
|
|
5
5
|
fmtr/tools/augmentation_tools.py,sha256=-6ESbO4CDlKqVOV1J1V6qBeoBMzbFIinkDHRHnCBej0,55
|
|
6
6
|
fmtr/tools/caching_tools.py,sha256=UOCYUNvLQ-NofR_dhqBmZF96-HRPf4At5MmxVk3gAIk,2943
|
|
7
|
-
fmtr/tools/config.py,sha256=
|
|
7
|
+
fmtr/tools/config.py,sha256=AUlNqXqJxB8muPwM7AQMDsET9B51BmMQaNr8YoROjNo,715
|
|
8
8
|
fmtr/tools/config_tools.py,sha256=27PbPYj90ClIW4QcRoUoiFM3SbWeMIIZsZR32IPU4V8,805
|
|
9
9
|
fmtr/tools/console_script_tools.py,sha256=T968S6fL--84G5ALaKwcTAzUOFyVhTU7Ts6qbk8oaeE,65
|
|
10
10
|
fmtr/tools/data_modelling_tools.py,sha256=bggZ-INJWr4depWC00lfXhzBtoFUOdon7Xahrj76vrY,574
|
|
@@ -23,7 +23,7 @@ fmtr/tools/interface_tools.py,sha256=fi0KW0veB2NQCmVmCA9iJUL_03gz0MD-gJ4OK-QUBVA
|
|
|
23
23
|
fmtr/tools/iterator_tools.py,sha256=xj5f0c7LgLK53dddRRRJxBoLaBzlZoQS3_GfmpDPMoo,1311
|
|
24
24
|
fmtr/tools/json_fix_tools.py,sha256=vNSlswVQnujPmKEqDjFJcO901mjMyv59q3awsT7mlhs,477
|
|
25
25
|
fmtr/tools/json_tools.py,sha256=IKmrANhcftIz2msCZeItidJ1PcpY_tnbfxbRDnta-c0,349
|
|
26
|
-
fmtr/tools/logging_tools.py,sha256=-
|
|
26
|
+
fmtr/tools/logging_tools.py,sha256=-4I-Wb76RBFyEpPKV0xWw5qVAyHnbnTaC7CkHdO6hx4,1757
|
|
27
27
|
fmtr/tools/merging_tools.py,sha256=KDxCEFJEQJEwGw1qGKAgR55uUE2X2S5NWLKcfHRmX_k,227
|
|
28
28
|
fmtr/tools/metric_tools.py,sha256=Lvia5CGFRIfrDFA8s37btIfTU5zHbo04cPJdAMtbndQ,272
|
|
29
29
|
fmtr/tools/name_tools.py,sha256=5CB_phqhHjl66iI8oLxOGPF2odC1apdul-M8Fv2xBhs,5514
|
|
@@ -41,7 +41,7 @@ fmtr/tools/string_tools.py,sha256=w0lw70bgzJ8tAHj_4lMrjtMyefE5kELgpCBgGzGcalo,31
|
|
|
41
41
|
fmtr/tools/tokenization_tools.py,sha256=9FP5vgPufWv0XA961eVKObFll0d_2mM0W3ut3rtZyeo,4329
|
|
42
42
|
fmtr/tools/tools.py,sha256=xnfUrOnrT4OxFYez6vV5tAhydzCICJFiGVnviiZDEQo,796
|
|
43
43
|
fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
|
|
44
|
-
fmtr/tools/version,sha256=
|
|
44
|
+
fmtr/tools/version,sha256=tMqbun-S_JrDZ7Qkw2sg9_dBM4nxyG1EwedIUztopKE,6
|
|
45
45
|
fmtr/tools/version_tools.py,sha256=pHxD425tc5JhGfMjE3-lRLnJOVPpf63Y5FGha5ntiVY,1112
|
|
46
46
|
fmtr/tools/yaml_tools.py,sha256=Ol43ZwbnSXGnn1K98Uxx61KPGSqfC4axE-X2q1LKMwk,349
|
|
47
47
|
fmtr/tools/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -52,9 +52,9 @@ fmtr/tools/tests/test_environment.py,sha256=iHaiMQfECYZPkPKwfuIZV9uHuWe3aE-p_dN_
|
|
|
52
52
|
fmtr/tools/tests/test_json.py,sha256=IeSP4ziPvRcmS8kq7k9tHonC9rN5YYq9GSNT2ul6Msk,287
|
|
53
53
|
fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g,2188
|
|
54
54
|
fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
|
|
55
|
-
fmtr.tools-1.0.
|
|
56
|
-
fmtr.tools-1.0.
|
|
57
|
-
fmtr.tools-1.0.
|
|
58
|
-
fmtr.tools-1.0.
|
|
59
|
-
fmtr.tools-1.0.
|
|
60
|
-
fmtr.tools-1.0.
|
|
55
|
+
fmtr.tools-1.0.27.dist-info/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
|
|
56
|
+
fmtr.tools-1.0.27.dist-info/METADATA,sha256=M4_BVM2K1c5IuabYoda-aF0NDPz0wbY09JNKdpYTSIQ,12942
|
|
57
|
+
fmtr.tools-1.0.27.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
58
|
+
fmtr.tools-1.0.27.dist-info/entry_points.txt,sha256=CEStVkwJ1mTFvhN1WV5RdW83SkNW1d5Syj-KZ6A19ng,72
|
|
59
|
+
fmtr.tools-1.0.27.dist-info/top_level.txt,sha256=t5341a8ii3n4RFizwTeXGmcq_pf4GqL1h9ylE5LIWRk,12
|
|
60
|
+
fmtr.tools-1.0.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|