move code from worker to libcommon
needed for https://github.com/huggingface/datasets-server/pull/2315


move code from worker to libcommon: needed for https://github.com/huggingface/datasets-server/pull/2315

