Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmonteiro committed May 8, 2024
1 parent 9077d05 commit 6be6a1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 48 deletions.
45 changes: 0 additions & 45 deletions tercen/http/HttpClientService.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ def multipart(self, uri, headers=None, parts=None):

class Response:
def __init__(self, httpResponseOrError):
# if httpResponseOrError is HTTPError:
# self.status = httpResponseOrError.code
# self.data = httpResponseOrError.read()
# else:
self.status = httpResponseOrError.status
self.stream = httpResponseOrError

Expand Down Expand Up @@ -273,35 +269,6 @@ def __init__(self, headers, bytes_data):
def toTson(self):
return {"headers":self.headers, "content":self.bytes_data}

# class MultiPartMixTransformerNonChunked:
# def __init__(self, frontier, parts):
# self.frontier = frontier
# self.parts = parts

# def encode_parts(self):
# data = bytearray()
# for part in self.parts:
# data.extend("--".encode("utf-8"))
# data.extend(self.frontier.encode("utf-8"))
# data.extend([13, 10])

# for key, value in part.headers.items():
# data.extend(key.encode("utf-8"))
# data.extend(": ".encode("utf-8"))
# data.extend(value.encode("utf-8"))
# data.extend([13, 10])

# data.extend([13, 10])
# data.extend(part.bytes_data)
# data.extend([13, 10])

# data.extend("--".encode("utf-8"))
# data.extend(self.frontier.encode("utf-8"))
# data.extend("--".encode("utf-8"))
# data.extend([13, 10])

# return data

class MultiPartMixTransformer:
def __init__(self, frontier, parts):
self.frontier = frontier
Expand Down Expand Up @@ -389,9 +356,6 @@ def __next__(self):

dataChunk = self.filePtr.read(512*1024)

# print("Reading chunk: {} [{} bytes]".format(self.currentFileChunk, len(dataChunk)))
# self.currentFileChunk += 1

if dataChunk is None or len(dataChunk) == 0:
self.currentPart = self.currentPart + 1
self.filePtr.close()
Expand Down Expand Up @@ -419,17 +383,8 @@ def __next__(self):

#FIXME Has to be a request object!
def encodeTSON(obj ):
# tson_bytes = ptson.encodeTSON(obj)
# tson_bytes.seek(0)
# encObj = tson_bytes.read()

# return ptson.encodeTSON(obj).getbuffer().tobytes()
return ptson.encodeTSON(obj).getbuffer().tobytes()


def decodeTSON(bts : Response):
# iobytes = io.BytesIO()
# iobytes.write(bts)
# iobytes.seek(0)
# decodedTson = ptson.decodeTSON(iobytes)
return ptson.decodeTSON(bts.stream)
5 changes: 3 additions & 2 deletions tercen/util/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def export_obj_pickle_to_project(context, data, fname, \
with gzip.open(fname, 'wb', compresslevel=compression) as f:
pickle.dump(data, f)

del data
data = []


file = FileDocument()
file.name = fname.split("/")[-1]
Expand All @@ -69,6 +68,8 @@ def export_obj_pickle_to_project(context, data, fname, \
context.client.fileService.uploadFromFile(file, fname)

if inplace == True:
del data
data = []
return data
else:
return None
2 changes: 1 addition & 1 deletion tercen/util/helper_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
import polars as pl
import numpy as np
import polars.datatypes.classes as plc


from io import BytesIO
import tempfile, string, random
Expand Down

0 comments on commit 6be6a1d

Please sign in to comment.