Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data_join): fix batch id error #1077

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions fedlearner/trainer/data_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,13 @@ def __init__(self,

datablocks = []
for dirname, _, filenames in tf.io.gfile.walk(data_path):
base_path = data_path
if os.path.basename(data_path) != 'batch':
base_path = os.path.dirname(data_path)
for filename in filenames:
if not fnmatch(os.path.join(dirname, filename), wildcard):
continue
subdirname = os.path.relpath(dirname, data_path)
subdirname = os.path.relpath(dirname, base_path)
block_id = os.path.join(subdirname, filename)
datablock = _RawDataBlock(
id=block_id, data_path=os.path.join(dirname, filename),
Expand All @@ -359,11 +362,14 @@ def __init__(self,
local_data_path)
local_datablocks = []
if local_data_path and tf.io.gfile.exists(local_data_path):
local_base_path = local_data_path
if os.path.basename(local_data_path) != 'batch':
local_base_path = os.path.dirname(local_data_path)
for dirname, _, filenames in tf.io.gfile.walk(local_data_path):
for filename in filenames:
if not fnmatch(os.path.join(dirname, filename), wildcard):
continue
subdirname = os.path.relpath(dirname, local_data_path)
subdirname = os.path.relpath(dirname, local_base_path)
block_id = os.path.join(subdirname, filename)
datablock = _RawDataBlock(
id=block_id, data_path=os.path.join(dirname, filename),
Expand Down