def rename(from_path, to_path, user=None):
fhost, fport, fpath = path.split(from_path, user)<EOL>thost, tport, tpath = path.split(to_path, user)<EOL>with hdfs(thost, tport, user) as fs:<EOL><INDENT>chost, cport = fs.host, fs.port<EOL><DEDENT>with hdfs(fhost, fport, user) as fs:<EOL><INDENT>if fs.host != chost or fs.port != cport:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>return fs.rename(fpath, tpath)<EOL><DEDENT>
See :meth:`fs.hdfs.rename`.