def __init__(self, task, pov_replace_unk): import nltk from nltk.translate.bleu_score import SmoothingFunction self._smooth_fn = SmoothingFunction().method4 nltk.download('wordnet', quiet=True) self.pov_replace_unk = pov_replace_unk dataset_name = PurePosixPath(task.args.data.split(':')[0]).name if dataset_name.startswith('java'): import javalang self._javalang = javalang self._parse_method = self._parse_java elif dataset_name.startswith('python'): self._javalang = None self._parse_method = self._parse_python # To fix the bug of original dataset (a temporarily solution). self._fix_python_orig_bug = dataset_name.endswith('orig') else: raise RuntimeError( 'code generation scorer requires only support Java and Python now, ' 'dataset name must be started with "java" or "python"') self.reset()
def clean_up_sqs() -> None: print("Deleting SQS queues whose age exceeds {}".format(MAX_AGE)) client = boto3.client("sqs") queues = client.list_queues() if "QueueUrls" in queues: for queue in queues["QueueUrls"]: name = PurePosixPath(unquote(urlparse(queue).path)).parts[2] if not name.startswith("testdrive"): print("Skipping non-testdrive queue {}".format(name)) continue attributes = client.get_queue_attributes( QueueUrl=queue, AttributeNames=["CreatedTimestamp"]) created_at = int(attributes["Attributes"]["CreatedTimestamp"]) age = datetime.now(timezone.utc) - datetime.fromtimestamp( created_at, timezone.utc) if age <= MAX_AGE: print( "Skipping queue {} whose age is beneath threshold".format( name)) continue print("Deleting SQS queue {} (age={})".format(name, age)) client.delete_queue(QueueUrl=queue)