mantisdk 0.1.0__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 mantisdk might be problematic. Click here for more details.
- mantisdk/__init__.py +22 -0
- mantisdk/adapter/__init__.py +15 -0
- mantisdk/adapter/base.py +94 -0
- mantisdk/adapter/messages.py +270 -0
- mantisdk/adapter/triplet.py +1028 -0
- mantisdk/algorithm/__init__.py +39 -0
- mantisdk/algorithm/apo/__init__.py +5 -0
- mantisdk/algorithm/apo/apo.py +889 -0
- mantisdk/algorithm/apo/prompts/apply_edit_variant01.poml +22 -0
- mantisdk/algorithm/apo/prompts/apply_edit_variant02.poml +18 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant01.poml +18 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant02.poml +16 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant03.poml +107 -0
- mantisdk/algorithm/base.py +162 -0
- mantisdk/algorithm/decorator.py +264 -0
- mantisdk/algorithm/fast.py +250 -0
- mantisdk/algorithm/gepa/__init__.py +59 -0
- mantisdk/algorithm/gepa/adapter.py +459 -0
- mantisdk/algorithm/gepa/gepa.py +364 -0
- mantisdk/algorithm/gepa/lib/__init__.py +18 -0
- mantisdk/algorithm/gepa/lib/adapters/README.md +12 -0
- mantisdk/algorithm/gepa/lib/adapters/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/README.md +341 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/__init__.py +1 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/anymaths_adapter.py +174 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/requirements.txt +1 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/README.md +0 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/default_adapter.py +209 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/README.md +7 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/dspy_adapter.py +307 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/README.md +99 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/dspy_program_proposal_signature.py +137 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/full_program_adapter.py +266 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/GEPA_RAG.md +621 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/__init__.py +56 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/evaluation_metrics.py +226 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/generic_rag_adapter.py +496 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/rag_pipeline.py +238 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_store_interface.py +212 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/__init__.py +2 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/chroma_store.py +196 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/lancedb_store.py +422 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/milvus_store.py +409 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/qdrant_store.py +368 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/weaviate_store.py +418 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/README.md +552 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/__init__.py +37 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_adapter.py +705 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_client.py +364 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/README.md +9 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/terminal_bench_adapter.py +217 -0
- mantisdk/algorithm/gepa/lib/api.py +375 -0
- mantisdk/algorithm/gepa/lib/core/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/core/adapter.py +180 -0
- mantisdk/algorithm/gepa/lib/core/data_loader.py +74 -0
- mantisdk/algorithm/gepa/lib/core/engine.py +356 -0
- mantisdk/algorithm/gepa/lib/core/result.py +233 -0
- mantisdk/algorithm/gepa/lib/core/state.py +636 -0
- mantisdk/algorithm/gepa/lib/examples/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/examples/aime.py +24 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/eval_default.py +111 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/instruction_prompt.txt +9 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/optimal_prompt.txt +24 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/train_anymaths.py +177 -0
- mantisdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/arc_agi.ipynb +25705 -0
- mantisdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/example.ipynb +348 -0
- mantisdk/algorithm/gepa/lib/examples/mcp_adapter/__init__.py +4 -0
- mantisdk/algorithm/gepa/lib/examples/mcp_adapter/mcp_optimization_example.py +455 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/RAG_GUIDE.md +613 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/__init__.py +9 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/rag_optimization.py +824 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/requirements-rag.txt +29 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/instruction_prompt.txt +16 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/terminus.txt +9 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/train_terminus.py +161 -0
- mantisdk/algorithm/gepa/lib/gepa_utils.py +117 -0
- mantisdk/algorithm/gepa/lib/logging/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/logging/experiment_tracker.py +187 -0
- mantisdk/algorithm/gepa/lib/logging/logger.py +75 -0
- mantisdk/algorithm/gepa/lib/logging/utils.py +103 -0
- mantisdk/algorithm/gepa/lib/proposer/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/proposer/base.py +31 -0
- mantisdk/algorithm/gepa/lib/proposer/merge.py +357 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/base.py +49 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/reflective_mutation.py +176 -0
- mantisdk/algorithm/gepa/lib/py.typed +0 -0
- mantisdk/algorithm/gepa/lib/strategies/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/strategies/batch_sampler.py +77 -0
- mantisdk/algorithm/gepa/lib/strategies/candidate_selector.py +50 -0
- mantisdk/algorithm/gepa/lib/strategies/component_selector.py +36 -0
- mantisdk/algorithm/gepa/lib/strategies/eval_policy.py +64 -0
- mantisdk/algorithm/gepa/lib/strategies/instruction_proposal.py +127 -0
- mantisdk/algorithm/gepa/lib/utils/__init__.py +10 -0
- mantisdk/algorithm/gepa/lib/utils/stop_condition.py +196 -0
- mantisdk/algorithm/gepa/tracing.py +105 -0
- mantisdk/algorithm/utils.py +177 -0
- mantisdk/algorithm/verl/__init__.py +5 -0
- mantisdk/algorithm/verl/interface.py +202 -0
- mantisdk/cli/__init__.py +56 -0
- mantisdk/cli/prometheus.py +115 -0
- mantisdk/cli/store.py +131 -0
- mantisdk/cli/vllm.py +29 -0
- mantisdk/client.py +408 -0
- mantisdk/config.py +348 -0
- mantisdk/emitter/__init__.py +43 -0
- mantisdk/emitter/annotation.py +370 -0
- mantisdk/emitter/exception.py +54 -0
- mantisdk/emitter/message.py +61 -0
- mantisdk/emitter/object.py +117 -0
- mantisdk/emitter/reward.py +320 -0
- mantisdk/env_var.py +156 -0
- mantisdk/execution/__init__.py +15 -0
- mantisdk/execution/base.py +64 -0
- mantisdk/execution/client_server.py +443 -0
- mantisdk/execution/events.py +69 -0
- mantisdk/execution/inter_process.py +16 -0
- mantisdk/execution/shared_memory.py +282 -0
- mantisdk/instrumentation/__init__.py +119 -0
- mantisdk/instrumentation/agentops.py +314 -0
- mantisdk/instrumentation/agentops_langchain.py +45 -0
- mantisdk/instrumentation/litellm.py +83 -0
- mantisdk/instrumentation/vllm.py +81 -0
- mantisdk/instrumentation/weave.py +500 -0
- mantisdk/litagent/__init__.py +11 -0
- mantisdk/litagent/decorator.py +536 -0
- mantisdk/litagent/litagent.py +252 -0
- mantisdk/llm_proxy.py +1890 -0
- mantisdk/logging.py +370 -0
- mantisdk/reward.py +7 -0
- mantisdk/runner/__init__.py +11 -0
- mantisdk/runner/agent.py +845 -0
- mantisdk/runner/base.py +182 -0
- mantisdk/runner/legacy.py +309 -0
- mantisdk/semconv.py +170 -0
- mantisdk/server.py +401 -0
- mantisdk/store/__init__.py +23 -0
- mantisdk/store/base.py +897 -0
- mantisdk/store/client_server.py +2092 -0
- mantisdk/store/collection/__init__.py +30 -0
- mantisdk/store/collection/base.py +587 -0
- mantisdk/store/collection/memory.py +970 -0
- mantisdk/store/collection/mongo.py +1412 -0
- mantisdk/store/collection_based.py +1823 -0
- mantisdk/store/insight.py +648 -0
- mantisdk/store/listener.py +58 -0
- mantisdk/store/memory.py +396 -0
- mantisdk/store/mongo.py +165 -0
- mantisdk/store/sqlite.py +3 -0
- mantisdk/store/threading.py +357 -0
- mantisdk/store/utils.py +142 -0
- mantisdk/tracer/__init__.py +16 -0
- mantisdk/tracer/agentops.py +242 -0
- mantisdk/tracer/base.py +287 -0
- mantisdk/tracer/dummy.py +106 -0
- mantisdk/tracer/otel.py +555 -0
- mantisdk/tracer/weave.py +677 -0
- mantisdk/trainer/__init__.py +6 -0
- mantisdk/trainer/init_utils.py +263 -0
- mantisdk/trainer/legacy.py +367 -0
- mantisdk/trainer/registry.py +12 -0
- mantisdk/trainer/trainer.py +618 -0
- mantisdk/types/__init__.py +6 -0
- mantisdk/types/core.py +553 -0
- mantisdk/types/resources.py +204 -0
- mantisdk/types/tracer.py +515 -0
- mantisdk/types/tracing.py +218 -0
- mantisdk/utils/__init__.py +1 -0
- mantisdk/utils/id.py +18 -0
- mantisdk/utils/metrics.py +1025 -0
- mantisdk/utils/otel.py +578 -0
- mantisdk/utils/otlp.py +536 -0
- mantisdk/utils/server_launcher.py +1045 -0
- mantisdk/utils/system_snapshot.py +81 -0
- mantisdk/verl/__init__.py +8 -0
- mantisdk/verl/__main__.py +6 -0
- mantisdk/verl/async_server.py +46 -0
- mantisdk/verl/config.yaml +27 -0
- mantisdk/verl/daemon.py +1154 -0
- mantisdk/verl/dataset.py +44 -0
- mantisdk/verl/entrypoint.py +248 -0
- mantisdk/verl/trainer.py +549 -0
- mantisdk-0.1.0.dist-info/METADATA +119 -0
- mantisdk-0.1.0.dist-info/RECORD +190 -0
- mantisdk-0.1.0.dist-info/WHEEL +4 -0
- mantisdk-0.1.0.dist-info/entry_points.txt +2 -0
- mantisdk-0.1.0.dist-info/licenses/LICENSE +19 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
|
|
3
|
+
"""Tracing configuration for algorithms.
|
|
4
|
+
|
|
5
|
+
This module provides a standardized way for algorithms to define their
|
|
6
|
+
tracing metadata (environment and tags) that flows through to Mantis/Insight.
|
|
7
|
+
|
|
8
|
+
It also provides infrastructure for call-type tagging, allowing algorithms
|
|
9
|
+
to define decorators that tag LLM calls (e.g., @gepa.judge, @gepa.agent).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import asyncio
|
|
13
|
+
import uuid
|
|
14
|
+
from contextvars import ContextVar
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from functools import wraps
|
|
17
|
+
from typing import Any, Callable, List, Optional, TypeVar
|
|
18
|
+
|
|
19
|
+
# Type variable for decorated functions
|
|
20
|
+
F = TypeVar("F", bound=Callable[..., Any])
|
|
21
|
+
|
|
22
|
+
# ============================================================================
|
|
23
|
+
# Call Type Context Propagation
|
|
24
|
+
# ============================================================================
|
|
25
|
+
|
|
26
|
+
# Context variable for the current LLM call type (agent, judge, reflection, etc.)
|
|
27
|
+
# This is used by instrumentation to tag spans appropriately.
|
|
28
|
+
_call_type_context: ContextVar[Optional[str]] = ContextVar("mantis_call_type", default=None)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_current_call_type() -> Optional[str]:
|
|
32
|
+
"""Get the current LLM call type from context.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The current call type (e.g., "agent-call", "judge-call") or None if not set.
|
|
36
|
+
"""
|
|
37
|
+
return _call_type_context.get()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def inject_call_type_header(extra_headers: Optional[dict] = None) -> dict:
|
|
41
|
+
"""Inject x-mantis-call-type header from context into extra_headers.
|
|
42
|
+
|
|
43
|
+
This reads the current call type from context (set by decorators like
|
|
44
|
+
@gepa.agent, @gepa.judge) and adds it to extra_headers for LLM calls.
|
|
45
|
+
The LLM proxy receives this header and tags the trace accordingly.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
extra_headers: Optional existing headers dict to merge into.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
A dict with x-mantis-call-type header if call type is set.
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
>>> @gepa.agent
|
|
55
|
+
>>> def my_agent(client):
|
|
56
|
+
... return client.chat.completions.create(
|
|
57
|
+
... model="gpt-4",
|
|
58
|
+
... messages=[...],
|
|
59
|
+
... extra_headers=inject_call_type_header()
|
|
60
|
+
... )
|
|
61
|
+
"""
|
|
62
|
+
if extra_headers is None:
|
|
63
|
+
extra_headers = {}
|
|
64
|
+
|
|
65
|
+
call_type = get_current_call_type()
|
|
66
|
+
if call_type:
|
|
67
|
+
extra_headers["x-mantis-call-type"] = call_type
|
|
68
|
+
|
|
69
|
+
return extra_headers
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def call_type_decorator(call_type: str) -> Callable[[F], F]:
|
|
73
|
+
"""Factory to create call-type tagging decorators.
|
|
74
|
+
|
|
75
|
+
This is used by algorithms to define their own call-type decorators.
|
|
76
|
+
When a decorated function executes, any LLM calls made within it
|
|
77
|
+
will be tagged with the specified call type.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
call_type: The call type tag (e.g., "agent-call", "judge-call").
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
A decorator that sets the call type context for the decorated function.
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
>>> # In algorithm/gepa/__init__.py
|
|
87
|
+
>>> agent = call_type_decorator("agent-call")
|
|
88
|
+
>>> judge = call_type_decorator("judge-call")
|
|
89
|
+
>>>
|
|
90
|
+
>>> # In user code
|
|
91
|
+
>>> @gepa.judge
|
|
92
|
+
>>> def grade_response(client, response, expected):
|
|
93
|
+
... return client.chat.completions.parse(...) # Tagged as "judge-call"
|
|
94
|
+
"""
|
|
95
|
+
def decorator(fn: F) -> F:
|
|
96
|
+
if asyncio.iscoroutinefunction(fn):
|
|
97
|
+
@wraps(fn)
|
|
98
|
+
async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
99
|
+
token = _call_type_context.set(call_type)
|
|
100
|
+
try:
|
|
101
|
+
return await fn(*args, **kwargs)
|
|
102
|
+
finally:
|
|
103
|
+
_call_type_context.reset(token)
|
|
104
|
+
return async_wrapper # type: ignore
|
|
105
|
+
else:
|
|
106
|
+
@wraps(fn)
|
|
107
|
+
def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
108
|
+
token = _call_type_context.set(call_type)
|
|
109
|
+
try:
|
|
110
|
+
return fn(*args, **kwargs)
|
|
111
|
+
finally:
|
|
112
|
+
_call_type_context.reset(token)
|
|
113
|
+
return sync_wrapper # type: ignore
|
|
114
|
+
return decorator
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@dataclass
|
|
118
|
+
class TracingConfig:
|
|
119
|
+
"""Configuration for algorithm-specific tracing metadata.
|
|
120
|
+
|
|
121
|
+
Each algorithm (GEPA, VERL, etc.) should define its own TracingConfig
|
|
122
|
+
to identify its traces in Mantis. The environment, tags, and session_id are
|
|
123
|
+
propagated through the LLM proxy and stored with traces.
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
>>> config = TracingConfig(
|
|
127
|
+
... environment="mantisdk-gepa",
|
|
128
|
+
... algorithm_name="gepa"
|
|
129
|
+
... )
|
|
130
|
+
>>> config.get_tags("train")
|
|
131
|
+
['gepa', 'train']
|
|
132
|
+
|
|
133
|
+
Attributes:
|
|
134
|
+
environment: The environment name for traces (e.g., "mantisdk-gepa").
|
|
135
|
+
This appears in Mantis's environment column.
|
|
136
|
+
algorithm_name: The algorithm identifier used as the base tag.
|
|
137
|
+
session_id: Unique session identifier for grouping related traces.
|
|
138
|
+
Auto-generated if not provided.
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
environment: str
|
|
142
|
+
algorithm_name: str
|
|
143
|
+
session_id: str = field(default_factory=lambda: f"session-{uuid.uuid4().hex[:12]}")
|
|
144
|
+
|
|
145
|
+
def get_tags(self, trace_type: str) -> List[str]:
|
|
146
|
+
"""Generate tags for a specific trace type.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
trace_type: The type of trace (e.g., "train", "validation",
|
|
150
|
+
"reflection", "test").
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
A list of tags: [algorithm_name, trace_type]
|
|
154
|
+
"""
|
|
155
|
+
return [self.algorithm_name, trace_type]
|
|
156
|
+
|
|
157
|
+
def get_detailed_tags(
|
|
158
|
+
self,
|
|
159
|
+
phase: str,
|
|
160
|
+
extra_tags: Optional[List[str]] = None,
|
|
161
|
+
) -> List[str]:
|
|
162
|
+
"""Generate tags with execution context.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
phase: Execution phase (e.g., "train", "validation", "reflection").
|
|
166
|
+
extra_tags: Optional algorithm-specific tags to append.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
A list of tags, e.g.: ["gepa", "train", "custom-tag"]
|
|
170
|
+
"""
|
|
171
|
+
tags = [self.algorithm_name, phase]
|
|
172
|
+
|
|
173
|
+
# Add any algorithm-specific extra tags
|
|
174
|
+
if extra_tags:
|
|
175
|
+
tags.extend(extra_tags)
|
|
176
|
+
|
|
177
|
+
return tags
|
|
178
|
+
|
|
179
|
+
def to_metadata(self, trace_type: Optional[str] = None) -> dict:
|
|
180
|
+
"""Convert to a metadata dict for rollouts or LLM calls.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
trace_type: Optional trace type to include in tags.
|
|
184
|
+
If None, only the algorithm_name is included in tags.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
Dict with "environment", "tags", and "session_id" keys.
|
|
188
|
+
"""
|
|
189
|
+
if trace_type:
|
|
190
|
+
tags = self.get_tags(trace_type)
|
|
191
|
+
else:
|
|
192
|
+
tags = [self.algorithm_name]
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
"environment": self.environment,
|
|
196
|
+
"tags": tags,
|
|
197
|
+
"session_id": self.session_id,
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
def to_detailed_metadata(
|
|
201
|
+
self,
|
|
202
|
+
phase: str,
|
|
203
|
+
extra_tags: Optional[List[str]] = None,
|
|
204
|
+
) -> dict:
|
|
205
|
+
"""Convert to a metadata dict with execution context.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
phase: Execution phase (e.g., "train", "validation", "reflection").
|
|
209
|
+
extra_tags: Optional algorithm-specific tags to append.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
Dict with "environment", "tags", and "session_id" keys.
|
|
213
|
+
"""
|
|
214
|
+
return {
|
|
215
|
+
"environment": self.environment,
|
|
216
|
+
"tags": self.get_detailed_tags(phase, extra_tags),
|
|
217
|
+
"session_id": self.session_id,
|
|
218
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Copyright (c) Microsoft. All rights reserved.
|
mantisdk/utils/id.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright (c) Microsoft. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
__all__ = ["generate_id"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def generate_id(length: int) -> str:
|
|
10
|
+
"""Generate a random ID of the given length.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
length: The length of the ID to generate.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
A random ID of the given length.
|
|
17
|
+
"""
|
|
18
|
+
return hashlib.sha1(uuid.uuid4().bytes).hexdigest()[:length]
|