benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f5ea2b3a-d488-5cf4-8afc-e4c197274694

Problem

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

complete prompt

import os
import shutil

# Constants
BACKUP_DIR = '/tmp/backup'

def task_func(directory):
    """
    Rollback the update of a directory by restoring it from a backup.
    
    Parameters:
    - directory (str): The directory path to rollback.
    
    Returns:
    - directory (str): The restored directory path if successful, otherwise an error message.
    
    Requirements:
    - os
    - shutil
    
    Constants:
    - BACKUP_DIR: The directory where backups are stored. Default is '/tmp/backup'.
    
    Examples:
    >>> task_func('/tmp/my_data')
    '/tmp/my_data'
    
    >>> task_func('/tmp/nonexistent')
    'Backup directory /tmp/backup does not exist. Cannot rollback update.'
    
    Note: 
    - This function will return the restored directory path on successful rollback, or an error message otherwise.
    """

instruct prompt

Rollback the update of a directory by restoring it from a backup. Constants: - BACKUP_DIR: The directory where backups are stored. Default is '/tmp/backup'. >>> task_func('/tmp/nonexistent') 'Backup directory /tmp/backup does not exist. Cannot rollback update.'
Note that: This function will return the restored directory path on successful rollback, or an error message otherwise.
The function should output with:
    directory (str): The restored directory path if successful, otherwise an error message.
You should write self-contained code starting with:

Code

import os
import shutil
# Constants
BACKUP_DIR = '/tmp/backup'
def task_func(directory):

code prompt

Code

import os
import shutil
# Constants
BACKUP_DIR = '/tmp/backup'
def task_func(directory):

entry point

task_func

libs

  • shutil
  • 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