benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7ec02984-ed33-5a49-b0ea-3f7554f70da9

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import subprocess
import os
import shutil
from glob import glob


def task_func(src_folder, dst_folder):
    """Compress all files in the specified source folder and move the compressed files to a destination folder.
    This operation is executed as a background process using the 'gzip' command.

    Parameters:
    src_folder (str): The path of the source folder containing the files to be compressed.
    dst_folder (str): The path of the destination folder where the compressed files will be moved.

    Returns:
    dict: A dictionary containing:
        - 'success': A boolean indicating if all files were compressed and moved successfully.
        - 'message': A descriptive message about the operation's result.
        - 'failed_files': A list of filenames that failed to compress or move.

    Requirements:
    - subprocess
    - os
    - shutil
    - glob
    - gzip

    Example:
    >>> import tempfile
    >>> import os
    >>> src_folder = tempfile.mkdtemp()
    >>> dst_folder = tempfile.mkdtemp()
    >>> for i in range(3):
    ...     with open(os.path.join(src_folder, f'file{i}.txt'), 'w') as f:
    ...         _ = f.write(f'This is file {i}.')
    >>> task_func(src_folder, dst_folder)
    {'success': True, 'message': 'All files compressed and moved successfully.', 'failed_files': []}
    """

instruct prompt

Compress all files in the specified source folder and move the compressed files to a destination folder. This operation is executed as a background process using the 'gzip' command.
The function should output with:
    dict: A dictionary containing:
    'success': A boolean indicating if all files were compressed and moved successfully.
    'message': A descriptive message about the operation's result.
    'failed_files': A list of filenames that failed to compress or move.
You should write self-contained code starting with:

Code

import subprocess
import os
import shutil
from glob import glob
def task_func(src_folder, dst_folder):

code prompt

Code

import subprocess
import os
import shutil
from glob import glob
def task_func(src_folder, dst_folder):

entry point

task_func

libs

  • glob
  • shutil
  • subprocess
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import