@@ -118,12 +118,17 @@ class Grid(MutableSequence):
118118 py.plot([trace], filename='graph from grid')
119119 ```
120120 """
121- def __init__ (self , columns_or_json ):
121+ def __init__ (self , columns_or_json , grid_id = None ):
122122 """
123123 Initialize a grid with an iterable of `plotly.grid_objs.Column`
124124 objects or a json/dict describing a grid. See second usage example
125125 below for the necessary structure of the dict.
126126
127+ :param (str|bool) grid_id: should not be accessible to users. Default
128+ is 'None' but if a grid is retrieved via `py.get_grid()` then the
129+ retrieved grid response will contain the grid_id which will be
130+ necessary to set `self.id` and `self._columns.id` below.
131+
127132 Example from iterable of columns:
128133 ```
129134 column_1 = Column([1, 2, 3], 'time')
@@ -141,9 +146,19 @@ def __init__(self, columns_or_json):
141146 grid = Grid(grid_json)
142147 ```
143148 """
144-
145149 # TODO: verify that columns are actually columns
146150 if isinstance (columns_or_json , dict ):
151+ # check that grid_id is entered
152+ if grid_id is None :
153+ raise exceptions .PlotlyError (
154+ "If you are manually converting a raw json/dict grid "
155+ "into a Grid instance, you must ensure that make "
156+ "'grid_id' is set to your file ID. This looks like "
157+ "'username:187'."
158+ )
159+ # TODO: verify that grid_id is a correct fid if a string
160+ self .id = grid_id
161+
147162 # check if 'cols' is a root key
148163 if 'cols' not in columns_or_json :
149164 raise exceptions .PlotlyError (
@@ -182,7 +197,8 @@ def __init__(self, columns_or_json):
182197
183198 # fill in uids
184199 for column in self :
185- column .id = columns_or_json ['cols' ][column .name ]['uid' ]
200+ column .id = self .id + ':' + columns_or_json ['cols' ][column .name ]['uid' ]
201+
186202 else :
187203 column_names = [column .name for column in columns_or_json ]
188204 duplicate_name = utils .get_first_duplicate (column_names )
@@ -193,8 +209,6 @@ def __init__(self, columns_or_json):
193209 self ._columns = list (columns_or_json )
194210 self .id = ''
195211
196- #self._fid = ''
197-
198212 def __repr__ (self ):
199213 return self ._columns .__repr__ ()
200214
@@ -241,7 +255,7 @@ def get_column(self, column_name):
241255 if column .name == column_name :
242256 return column
243257
244- def get_uid (self , column_name ):
258+ def get_fid_uid (self , column_name ):
245259 """
246260 Return uid of given column name in the grid by column name.
247261
0 commit comments