Skip to content

Commit

Permalink
Merge pull request #8535 from OpenMined/upgrade-result
Browse files Browse the repository at this point in the history
Upgrade result Library to version 0.16.0 and pycapnp
  • Loading branch information
shubham3121 authored Mar 1, 2024
2 parents 1251355 + aa6928a commit 03e0e7b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 59 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
certifi>=2023.7.22 # not directly required, pinned by Snyk to avoid a vulnerability
ipython==8.10.0
jinja2>=3.1.3 # not directly required, pinned by Snyk to avoid a vulnerability
markupsafe==2.0.1
pydata-sphinx-theme==0.7.2
pygments>=2.15.0 # not directly required, pinned by Snyk to avoid a vulnerability
Expand All @@ -10,4 +11,3 @@ sphinx-autoapi==1.8.4
sphinx-code-include==1.1.1
sphinx-copybutton==0.4.0
sphinx-panels==0.6.0
jinja2>=3.1.3 # not directly required, pinned by Snyk to avoid a vulnerability
5 changes: 3 additions & 2 deletions packages/syft/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ syft =
networkx==2.8
packaging>=23.0
pyarrow==14.0.1
pycapnp==1.3.0
# pycapnp is beta version, update to stable version when available
pycapnp==2.0.0b2
pydantic[email]==1.10.13
pymongo==4.6.1
pynacl==1.5.0
pyzmq>=23.2.1,<=25.1.1
redis==4.6.0
requests==2.31.0
RestrictedPython==7.0
result==0.10.0
result==0.16.0
tqdm==4.66.1
typeguard==2.13.3
typing_extensions==4.8.0
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/store/document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def init_store(self) -> Result[Ok, Err]:
except BaseException as e:
return Err(str(e))

return Ok()
return Ok(True)

def matches_unique_cks(self, partition_key: PartitionKey) -> bool:
return partition_key in self.unique_cks
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/store/kv_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def init_store(self) -> Result[Ok, Err]:
except BaseException as e:
return Err(str(e))

return Ok()
return Ok(True)

def __len__(self) -> int:
return len(self.data)
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/store/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def connect(self, config: MongoStoreClientConfig) -> Result[Ok, Err]:
self.client = None
return Err(str(e))

return Ok()
return Ok(True)

def with_db(self, db_name: str) -> Result[MongoDatabase, Err]:
try:
Expand Down
6 changes: 3 additions & 3 deletions packages/syft/src/syft/store/mongo_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def check_index_keys(current_keys, new_index_keys):
if current_index_keys is not None:
keys_same = check_index_keys(current_index_keys["key"], new_index_keys)
if keys_same:
return Ok()
return Ok(True)

# Drop current index, since incompatible with current object
try:
Expand All @@ -202,7 +202,7 @@ def check_index_keys(current_keys, new_index_keys):

# If no new indexes, then skip index creation
if len(new_index_keys) == 0:
return Ok()
return Ok(True)

try:
collection.create_index(new_index_keys, unique=True, name=index_name)
Expand All @@ -211,7 +211,7 @@ def check_index_keys(current_keys, new_index_keys):
f"Failed to create index for {object_name} with index keys: {new_index_keys}"
)

return Ok()
return Ok(True)

@property
def collection(self) -> Result[MongoCollection, Err]:
Expand Down
102 changes: 52 additions & 50 deletions packages/syft/src/syft/util/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,55 @@ def noop(__func_or_class: T, /, *args: Any, **kwargs: Any) -> T:

if not TRACE_MODE:
instrument = noop

try:
print("OpenTelemetry Tracing enabled")
service_name = os.environ.get("SERVICE_NAME", "client")
jaeger_host = os.environ.get("JAEGER_HOST", "localhost")
jaeger_port = int(os.environ.get("JAEGER_PORT", "14268"))

# third party
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.resources import SERVICE_NAME
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

trace.set_tracer_provider(
TracerProvider(resource=Resource.create({SERVICE_NAME: service_name}))
)
jaeger_exporter = JaegerExporter(
# agent_host_name=jaeger_host,
# agent_port=jaeger_port,
collector_endpoint=f"http://{jaeger_host}:{jaeger_port}/api/traces?format=jaeger.thrift",
# udp_split_oversized_batches=True,
)

trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(jaeger_exporter))

# from opentelemetry.sdk.trace.export import ConsoleSpanExporter
# console_exporter = ConsoleSpanExporter()
# span_processor = BatchSpanProcessor(console_exporter)
# trace.get_tracer_provider().add_span_processor(span_processor)

# third party
import opentelemetry.instrumentation.requests

opentelemetry.instrumentation.requests.RequestsInstrumentor().instrument()

# relative
# from opentelemetry.instrumentation.digma.trace_decorator import (
# instrument as _instrument,
# )
#
# until this is merged:
# https://github.com/digma-ai/opentelemetry-instrumentation-digma/pull/41
from .trace_decorator import instrument as _instrument

instrument = _instrument
except Exception: # nosec
print("Failed to import opentelemetry")
instrument = noop
else:
try:
print("OpenTelemetry Tracing enabled")
service_name = os.environ.get("SERVICE_NAME", "client")
jaeger_host = os.environ.get("JAEGER_HOST", "localhost")
jaeger_port = int(os.environ.get("JAEGER_PORT", "14268"))

# third party
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.resources import SERVICE_NAME
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

trace.set_tracer_provider(
TracerProvider(resource=Resource.create({SERVICE_NAME: service_name}))
)
jaeger_exporter = JaegerExporter(
# agent_host_name=jaeger_host,
# agent_port=jaeger_port,
collector_endpoint=f"http://{jaeger_host}:{jaeger_port}/api/traces?format=jaeger.thrift",
# udp_split_oversized_batches=True,
)

trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(jaeger_exporter)
)

# from opentelemetry.sdk.trace.export import ConsoleSpanExporter
# console_exporter = ConsoleSpanExporter()
# span_processor = BatchSpanProcessor(console_exporter)
# trace.get_tracer_provider().add_span_processor(span_processor)

# third party
import opentelemetry.instrumentation.requests

opentelemetry.instrumentation.requests.RequestsInstrumentor().instrument()

# relative
# from opentelemetry.instrumentation.digma.trace_decorator import (
# instrument as _instrument,
# )
#
# until this is merged:
# https://github.com/digma-ai/opentelemetry-instrumentation-digma/pull/41
from .trace_decorator import instrument as _instrument

instrument = _instrument
except Exception: # nosec
print("Failed to import opentelemetry")
instrument = noop

0 comments on commit 03e0e7b

Please sign in to comment.