Skip to content

Commit

Permalink
make OSX not use multiprocessing or freezing support instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jiakf committed Jun 20, 2024
1 parent 444113a commit 96a481b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gdc_client/parcel/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from intervaltree import Interval, IntervalTree

from gdc_client.parcel.portability import OS_WINDOWS
from gdc_client.parcel.portability import OS_OSX, OS_WINDOWS
from gdc_client.parcel.utils import (
get_file_transfer_pbar,
get_percentage_pbar,
Expand All @@ -30,7 +30,7 @@
)
from gdc_client.parcel.const import SAVE_INTERVAL

if OS_WINDOWS:
if OS_WINDOWS or OS_OSX:
WINDOWS = True
from queue import Queue
else:
Expand Down
8 changes: 3 additions & 5 deletions gdc_client/upload/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import yaml
from lxml import etree

from gdc_client.parcel import portability
from gdc_client.parcel.utils import get_file_transfer_pbar, get_percentage_pbar
from gdc_client.upload import manifest

Expand All @@ -27,7 +28,7 @@

OS_WINDOWS = platform.system() == "Windows"

if not OS_WINDOWS:
if not OS_WINDOWS or portability.OS_OSX:
from mmap import PROT_READ
else:
from multiprocessing import freeze_support
Expand Down Expand Up @@ -77,7 +78,7 @@ def upload_multipart(
try:
log.debug(f"Start upload part {part_number}")
with open(filename, "rb") as source:
if OS_WINDOWS:
if OS_WINDOWS or portability.OS_OSX:
chunk_file = mmap(
fileno=source.fileno(),
length=num_bytes,
Expand Down Expand Up @@ -112,7 +113,6 @@ def upload_multipart(
log.debug(f"Retry upload part {part_number}, {res.content}")

except Exception as e:

if debug:
log.exception(f"Part upload failed: {e}. Retrying")

Expand Down Expand Up @@ -178,7 +178,6 @@ def __init__(
def _get_node_metadata_via_graphql(
self, node_id, node_type="node", fields=("project_id", "file_name")
):

query_template = 'query Files { %s (id: "%s") { %s } }'
query = {
"query": query_template % (node_type, node_id, " ".join(fields)),
Expand Down Expand Up @@ -367,7 +366,6 @@ def upload(self):
if not self.multipart:
self._upload()
else:

if self.file_size < self.upload_part_size:
log.info(
"File size smaller than part size {}, do simple upload".format(
Expand Down

0 comments on commit 96a481b

Please sign in to comment.