Skip to content

Commit

Permalink
Move to uuid instead
Browse files Browse the repository at this point in the history
  • Loading branch information
plaguss committed Jul 23, 2024
1 parent 632c5f0 commit cb3e3fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
16 changes: 2 additions & 14 deletions src/distilabel/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import hashlib
import logging
import os
import random
import signal
import string
import threading
import time
import uuid
from abc import ABC, abstractmethod
from pathlib import Path
from typing import (
Expand Down Expand Up @@ -124,17 +123,6 @@ def get_pipeline(cls) -> Union["BasePipeline", None]:
_STEP_NOT_LOADED_CODE = -999


def generate_random_name(num_chars: int = 8) -> str:
"""Helper function to generate a random name for a pipeline by default.
Returns:
Random name for a pipeline.
"""
return "pipeline_" + "".join(
random.choice(string.ascii_letters + string.digits) for _ in range(num_chars)
)


class BasePipeline(ABC, RequirementsMixin, _Serializable):
"""Base class for a `distilabel` pipeline.
Expand Down Expand Up @@ -191,7 +179,7 @@ def __init__(
Defaults to `None`, but can be helpful to inform in a pipeline to be shared
that this requirements must be installed.
"""
self.name = name or generate_random_name()
self.name = name or str(uuid.uuid4())[:8]
self.description = description
self._enable_metadata = enable_metadata
self.dag = DAG()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/pipeline/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def test_optional_name(self):

random.seed(42)
with DummyPipeline() as pipeline:
assert pipeline.name == "pipeline_OhbVrpoi"
assert pipeline.name == "pipeline_b4e126e6"


class TestPipelineSerialization:
Expand Down

0 comments on commit cb3e3fb

Please sign in to comment.