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

After call NeighborLoader my file logger prints in console #9892

Open
munkhbuyan opened this issue Dec 26, 2024 · 3 comments
Open

After call NeighborLoader my file logger prints in console #9892

munkhbuyan opened this issue Dec 26, 2024 · 3 comments

Comments

@munkhbuyan
Copy link

munkhbuyan commented Dec 26, 2024

🐛 Describe the bug

After call bellow, my file logger outputs to console, and changed the log format. Except that all fine. Could you tell me it is bug or i did wrong?

Versions

train_loader = NeighborLoader(
                                dataset._data,
                                num_neighbors = {key: NEIGHBOR_SIZES for key in dataset._data.edge_types},
                                batch_size=BATCH_SIZE,
                                input_nodes=('user', train_mask)
                                )

My logger:

def get_file_pylogger(filepath: str, name: str = __name__) -> logging.Logger:
    """Initialize .log file logger"""
    formatter = logging.Formatter(
        fmt="%(asctime)s %(levelname)s %(message)s",
        datefmt="%Y-%m-%d %H:%M:%S",
    )
    logger = logging.getLogger(name)
    file_handler = logging.FileHandler(filepath, "a+")
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    logger.setLevel(logging.DEBUG)
    return logger
@munkhbuyan munkhbuyan added the bug label Dec 26, 2024
@munkhbuyan munkhbuyan changed the title after call NeighborLoader my file logger prints in console After call NeighborLoader my file logger prints in console Dec 26, 2024
@akihironitta
Copy link
Member

I'm not sure if I correctly understand what issue you're experiencing. Can you elaborate more? What's the expected behaviour? Can you share a minimal script and env details that reproduces the misbehaviour you're referring to?

@munkhbuyan
Copy link
Author

I am using two types of loaders. if sampler is not 'neighbor', log.info outputs to file. if sampler is 'neighbor', log.info outputs file and console. I thoughts it is NeighborLoader's bug related with standard output. Maybe i did wrong with log.

file_log = util.get_file_pylogger(os.path.join(path,'run_logs', logfilename), 'filelogger')
log.handlers.append(file_log.handlers[0])
...
if SAMPLER == 'neighbor':
      train_loader = NeighborLoader(
          dataset._data,
          num_neighbors = {key: NEIGHBOR_SIZES for key in dataset._data.edge_types},
          batch_size=BATCH_SIZE,
          input_nodes=('user', train_mask)
          )
else:
      train_loader = DataLoader(dataset, batch_size=BATCH_SIZE)
...
log.info('result')

@akihironitta
Copy link
Member

akihironitta commented Dec 28, 2024

Mind sharing minimal code I can run for reproduction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants