Ejemplo n.º 1
0
    def testPathSeparator(self):
        # In nix systems, path separator would be the same as that of CNS/GCS
        # making it hard to tell if something went wrong.
        self.stubs.Set(os, "sep", "#")

        self.assertEqual(io_wrapper.PathSeparator("/tmp/foo"), "#")
        self.assertEqual(io_wrapper.PathSeparator("tmp/foo"), "#")
        self.assertEqual(io_wrapper.PathSeparator("/cns/tmp/foo"), "/")
        self.assertEqual(io_wrapper.PathSeparator("gs://foo"), "/")
Ejemplo n.º 2
0
    def testPathSeparator(self):
        # In nix systems, path separator would be the same as that of CNS/GCS
        # making it hard to tell if something went wrong.
        self.stubs.Set(os, 'sep', '#')

        self.assertEqual(io_wrapper.PathSeparator('/tmp/foo'), '#')
        self.assertEqual(io_wrapper.PathSeparator('tmp/foo'), '#')
        self.assertEqual(io_wrapper.PathSeparator('/cns/tmp/foo'), '/')
        self.assertEqual(io_wrapper.PathSeparator('gs://foo'), '/')
 def _get_exp_and_run_names(self, path, subdir, experiment_name_override=None):
   if experiment_name_override is not None:
     return (experiment_name_override, os.path.relpath(subdir, path))
   sep = io_wrapper.PathSeparator(path)
   path_parts = os.path.relpath(subdir, path).split(sep, 1)
   experiment_name = path_parts[0]
   run_name = path_parts[1] if len(path_parts) == 2 else '.'
   return (experiment_name, run_name)