Skip to content

Commit

Permalink
2/n Remove simplejson dependency
Browse files Browse the repository at this point in the history
Summary: Remove our dependency on simplejson, which we were only using as way of converting named tuples to dicts. Now we have our own utility for this.

Reviewed By: kkashin

Differential Revision: D15313782

fbshipit-source-id: 1c7ae622caed80ceae6d8ecf3f88986228e601a3
  • Loading branch information
ldworkin authored and facebook-github-bot committed May 13, 2019
1 parent 4a741e3 commit 10b3a9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 4 additions & 7 deletions ax/plot/base.py
Expand Up @@ -2,10 +2,11 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

import enum
import json
from typing import Any, Dict, List, NamedTuple, Optional, Union

import simplejson
from ax.core.types import TParameterization
from ax.utils.common.serialization import named_tuple_to_dict
from plotly import utils


Expand Down Expand Up @@ -37,12 +38,8 @@ class AxPlotConfig(_AxPlotConfigBase):
def __new__(cls, data: Dict[str, Any], plot_type: enum.Enum) -> "AxPlotConfig":
# Convert data to json-encodable form (strips out NamedTuple and numpy
# array). This is a lossy conversion.
dict_data = simplejson.loads(
simplejson.dumps(
data,
cls=utils.PlotlyJSONEncoder,
namedtuple_as_object=True, # uses NamesTuple's `_asdict()`
)
dict_data = json.loads(
json.dumps(named_tuple_to_dict(data), cls=utils.PlotlyJSONEncoder)
)
# pyre-fixme[7]: Expected `AxPlotConfig` but got `_AxPlotConfigBase`.
return super(AxPlotConfig, cls).__new__(cls, dict_data, plot_type)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -14,7 +14,6 @@
"jinja2", # also a Plotly dep
"pandas",
"scipy",
"simplejson",
"sklearn",
"plotly>=2.2.1,<3.0",
]
Expand Down

0 comments on commit 10b3a9f

Please sign in to comment.