@@ -66,11 +66,11 @@ def version(self) -> bigframes.series.Series:
66
66
67
67
Returns:
68
68
BigFrames Series: Version as string."""
69
- # version must be retrived after fetching metadata
69
+ # version must be retrieved after fetching metadata
70
70
return self ._apply_unary_op (ops .obj_fetch_metadata_op ).struct .field ("version" )
71
71
72
72
def metadata (self ) -> bigframes .series .Series :
73
- """Retrive the metadata of the Blob.
73
+ """Retrieve the metadata of the Blob.
74
74
75
75
.. note::
76
76
BigFrames Blob is still under experiments. It may not work and subject to change in the future.
@@ -85,7 +85,7 @@ def metadata(self) -> bigframes.series.Series:
85
85
return bbq .json_extract (details_json , "$.gcs_metadata" ).rename ("metadata" )
86
86
87
87
def content_type (self ) -> bigframes .series .Series :
88
- """Retrive the content type of the Blob.
88
+ """Retrieve the content type of the Blob.
89
89
90
90
.. note::
91
91
BigFrames Blob is still under experiments. It may not work and subject to change in the future.
@@ -99,7 +99,7 @@ def content_type(self) -> bigframes.series.Series:
99
99
)
100
100
101
101
def md5_hash (self ) -> bigframes .series .Series :
102
- """Retrive the md5 hash of the Blob.
102
+ """Retrieve the md5 hash of the Blob.
103
103
104
104
.. note::
105
105
BigFrames Blob is still under experiments. It may not work and subject to change in the future.
@@ -113,7 +113,7 @@ def md5_hash(self) -> bigframes.series.Series:
113
113
)
114
114
115
115
def size (self ) -> bigframes .series .Series :
116
- """Retrive the file size of the Blob.
116
+ """Retrieve the file size of the Blob.
117
117
118
118
.. note::
119
119
BigFrames Blob is still under experiments. It may not work and subject to change in the future.
@@ -128,7 +128,7 @@ def size(self) -> bigframes.series.Series:
128
128
)
129
129
130
130
def updated (self ) -> bigframes .series .Series :
131
- """Retrive the updated time of the Blob.
131
+ """Retrieve the updated time of the Blob.
132
132
133
133
.. note::
134
134
BigFrames Blob is still under experiments. It may not work and subject to change in the future.
@@ -146,6 +146,46 @@ def updated(self) -> bigframes.series.Series:
146
146
147
147
return bpd .to_datetime (updated , unit = "us" , utc = True )
148
148
149
+ def _get_runtime (
150
+ self , mode : str , with_metadata : bool = False
151
+ ) -> bigframes .series .Series :
152
+ """Retrieve the ObjectRefRuntime as JSON.
153
+
154
+ Args:
155
+ mode (str): mode for the URLs, "R" for read, "RW" for read & write.
156
+ metadata (bool, default False): whether to fetch the metadata in the ObjectRefRuntime.
157
+
158
+ Returns:
159
+ bigframes Series: ObjectRefRuntime JSON.
160
+ """
161
+ s = self ._apply_unary_op (ops .obj_fetch_metadata_op ) if with_metadata else self
162
+
163
+ return s ._apply_unary_op (ops .ObjGetAccessUrl (mode = mode ))
164
+
165
+ def read_url (self ) -> bigframes .series .Series :
166
+ """Retrieve the read URL of the Blob.
167
+
168
+ .. note::
169
+ BigFrames Blob is still under experiments. It may not work and subject to change in the future.
170
+
171
+ Returns:
172
+ BigFrames Series: Read only URLs."""
173
+ return self ._get_runtime (mode = "R" )._apply_unary_op (
174
+ ops .JSONValue (json_path = "$.access_urls.read_url" )
175
+ )
176
+
177
+ def write_url (self ) -> bigframes .series .Series :
178
+ """Retrieve the write URL of the Blob.
179
+
180
+ .. note::
181
+ BigFrames Blob is still under experiments. It may not work and subject to change in the future.
182
+
183
+ Returns:
184
+ BigFrames Series: Writable URLs."""
185
+ return self ._get_runtime (mode = "RW" )._apply_unary_op (
186
+ ops .JSONValue (json_path = "$.access_urls.write_url" )
187
+ )
188
+
149
189
def display (self , n : int = 3 , * , content_type : str = "" ):
150
190
"""Display the blob content in the IPython Notebook environment. Only works for image type now.
151
191
@@ -159,10 +199,7 @@ def display(self, n: int = 3, *, content_type: str = ""):
159
199
# col name doesn't matter here. Rename to avoid column name conflicts
160
200
df = bigframes .series .Series (self ._block ).rename ("blob_col" ).head (n ).to_frame ()
161
201
162
- obj_ref_runtime = df ["blob_col" ]._apply_unary_op (ops .ObjGetAccessUrl (mode = "R" ))
163
- df ["read_url" ] = obj_ref_runtime ._apply_unary_op (
164
- ops .JSONValue (json_path = "$.access_urls.read_url" )
165
- )
202
+ df ["read_url" ] = df ["blob_col" ].blob .read_url ()
166
203
167
204
if content_type :
168
205
df ["content_type" ] = content_type
@@ -231,10 +268,8 @@ def image_blur(
231
268
connection = connection ,
232
269
).udf ()
233
270
234
- src_rt = bigframes .series .Series (self ._block )._apply_unary_op (
235
- ops .ObjGetAccessUrl (mode = "R" )
236
- )
237
- dst_rt = dst ._apply_unary_op (ops .ObjGetAccessUrl (mode = "RW" ))
271
+ src_rt = self ._get_runtime (mode = "R" )
272
+ dst_rt = dst .blob ._get_runtime (mode = "RW" )
238
273
239
274
src_rt = src_rt ._apply_unary_op (ops .ToJSONString ())
240
275
dst_rt = dst_rt ._apply_unary_op (ops .ToJSONString ())
0 commit comments