Skip to content

Commit

Permalink
reformat code using black
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchy27 committed Jun 22, 2023
1 parent bea58fd commit 8c81441
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions metaflow/multicore_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from multiprocessing import cpu_count
from tempfile import NamedTemporaryFile
import metaflow.tracing as tracing

try:
# Python 2
import cPickle as pickle
Expand Down Expand Up @@ -60,15 +61,13 @@ def _spawn(func, arg, dir):


def parallel_imap_unordered(func, iterable, max_parallel=None, dir=None):

if max_parallel is None:
max_parallel = cpu_count()

args_iter = iter(iterable)
pids = [_spawn(func, arg, dir) for arg in islice(args_iter, max_parallel)]

while pids:

pid, output_file = pids.pop()
if os.waitpid(pid, 0)[1]:
raise MulticoreException("Child failed")
Expand Down
1 change: 0 additions & 1 deletion metaflow/sidecar/sidecar_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def __init__(self, worker_type):
self.start()

def start(self):

if (
self._worker_type is not None
and self._worker_type.startswith(NULL_SIDECAR_PREFIX)
Expand Down
1 change: 1 addition & 0 deletions metaflow/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def wrapper_func(*args, **kwargs):

return wrapper_func


if CONSOLE_TRACE_ENABLED or OTEL_ENDPOINT or ZIPKIN_ENDPOINT:
try:
from .tracing_modules import *
Expand Down
15 changes: 8 additions & 7 deletions metaflow/tracing/span_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
from metaflow.metaflow_config import (
OTEL_ENDPOINT,
ZIPKIN_ENDPOINT,
CONSOLE_TRACE_ENABLED
CONSOLE_TRACE_ENABLED,
)

from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.exporter.zipkin.proto.http import ZipkinExporter

from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import ConsoleSpanExporter


def get_span_exporter():
if OTEL_ENDPOINT:
return set_otel_exporter()

elif ZIPKIN_ENDPOINT:
return set_zipkin_exporter()
elif CONSOLE_TRACE_ENABLED:
Expand All @@ -25,7 +26,6 @@ def get_span_exporter():
return



def set_otel_exporter():
from metaflow.metaflow_config import (
SERVICE_AUTH_KEY,
Expand All @@ -49,13 +49,14 @@ def set_otel_exporter():
return
return span_exporter


def set_zipkin_exporter():
span_exporter = ZipkinExporter(
endpoint=ZIPKIN_ENDPOINT,
)
endpoint=ZIPKIN_ENDPOINT,
)
return span_exporter


def set_console_exporter():
span_exporter = ConsoleSpanExporter()
return span_exporter

3 changes: 1 addition & 2 deletions metaflow/tracing/tracing_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

tracer_provider = None


def init_tracing():
global tracer_provider
if tracer_provider is not None:
Expand All @@ -26,7 +27,6 @@ def init_tracing():
set_global_textmap(EnvPropagator(None))
span_exporter = get_span_exporter()


if "METAFLOW_KUBERNETES_POD_NAMESPACE" in os.environ:
service_name = "metaflow-kubernetes"
elif "AWS_BATCH_JOB_ID" in os.environ:
Expand All @@ -47,7 +47,6 @@ def init_tracing():
RequestsInstrumentor().instrument()



@contextlib.contextmanager
def post_fork():
global tracer_provider
Expand Down

0 comments on commit 8c81441

Please sign in to comment.