The issue with the second way is expected, as Ray cannot access modules that are not in PYTHONPATH (see TorchTrain fails if train_func imports functions from a different file for more details).
Would it be possible for you to provide a simple reproducible example that we can run on our side without external dependencies?