Best Python code snippet using slash
state.py
Source:state.py  
...24import uv.util.env as ue25from uv.reporter.base import AbstractReporter26from uv.reporter.store import NullReporter27_active_reporter = None28def get_reporter() -> AbstractReporter:29  """Returns the active reporter set using set_reporter()"""30  if _active_reporter is not None:31    return _active_reporter32  return NullReporter()33def set_reporter(r: AbstractReporter) -> AbstractReporter:34  """Set the globally available reporter instance. Returns its input."""35  global _active_reporter36  _active_reporter = r37  return _active_reporter38@contextmanager39def active_reporter(r: AbstractReporter):40  old_reporter = _active_reporter41  globals()['_active_reporter'] = r42  yield r43  globals()['_active_reporter'] = old_reporter44def report(step: int, k: t.MetricKey, v: t.Metric) -> None:45  """Accepts a step (an ordered int referencing some timestep), a metric key and46    a value, and persists the metric into the globally available reporter47    returned by uv.get_reporter().48  """49  return get_reporter().report(step, k, v)50def report_all(step: int, m: Dict[t.MetricKey, t.Metric]) -> None:51  """Accepts a step (an ordered int referencing some timestep) and a dictionary52    of metric key => metric value, and persists the metric into the globally53    available reporter returned by uv.get_reporter().54  """55  return get_reporter().report_all(step, m)56def report_param(k: str, v: str) -> None:57  """Accepts a key and value parameter and logs these as parameters alongside the58    reported metrics. Reports to the globally available reporter returned by59    uv.get_reporter().60    """61  return get_reporter().report_param(k, v)62def report_params(m: Dict[str, str]) -> None:63  """Accepts a dict of parameter name -> value, and logs these as parameters64  alongside the reported metrics. Reports to the globally available reporter65  returned by uv.get_reporter().66  """67  return get_reporter().report_params(m)68def _ensure_non_null_project(artifact_root: Optional[str]):69  '''Ensures that the google cloud python api methods can get a non-None70  project id when the mlflow artifact root is a storage bucket. This is necessary71  because mlflow uses google.cloud.storage.Client() to create a client instance,72  which requires a project. This project name does not appear to need to be valid for73  reading and writing artifacts, so we set it to a placeholder string if there is74  no project available via the standard api methods.75  '''76  if artifact_root is None:77    return78  if not artifact_root.startswith('gs://'):79    return80  _, project_id = google.auth.default()81  if project_id is not None:...test_dlrn.py
Source:test_dlrn.py  
...10    """ Test config generator """11    return {'url': 'test/url',12            'title': 'Test Error'}13@pytest.fixture()14def get_reporter():15    """ Test reporter mock generator """16    reporter = create_autospec(BaseReport)17    return reporter18@pytest.fixture()19def get_report():20    """ Test reporter mock generator """21    report = create_autospec(BaseReport)22    return report23def test_is_base(get_config, get_reporter):24    """25    Given we have DlrnFTBFSError object26    When we check the subclass is BaseError27    Then we get True28    """...many_to_one_null.py
Source:many_to_one_null.py  
...21>>> a = articles.Article(headline="First", reporter=r)22>>> a.save()23>>> a.reporter_id24125>>> a.get_reporter()26John Smith27# Article objects have access to their related Reporter objects.28>>> r = a.get_reporter()29# Create an Article via the Reporter object.30>>> a2 = r.add_article(headline="Second")31>>> a232Second33>>> a2.reporter_id34135# Reporter objects have access to their related Article objects.36>>> r.get_article_list(order_by=['headline'])37[First, Second]38>>> r.get_article(headline__startswith='Fir')39First40>>> r.get_article_count()41242# Create an Article with no Reporter by passing "reporter=None".43>>> a3 = articles.Article(headline="Third", reporter=None)44>>> a3.save()45>>> a3.id46347>>> a3.reporter_id48>>> print a3.reporter_id49None50>>> a3 = articles.get_object(pk=3)51>>> print a3.reporter_id52None53# An article's get_reporter() method throws ReporterDoesNotExist54# if the reporter is set to None.55>>> a3.get_reporter()56Traceback (most recent call last):57    ...58ReporterDoesNotExist59# To retrieve the articles with no reporters set, use "reporter__isnull=True".60>>> articles.get_list(reporter__isnull=True)61[Third]...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
