id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
166,512
import os from absl import logging from tfx import v1 as tfx from tfx.experimental.templates.penguin.pipeline import configs from tfx.experimental.templates.penguin.pipeline import pipeline PIPELINE_ROOT = os.path.join(OUTPUT_DIR, 'tfx_pipeline_output', configs.PIPELINE_NAME) SERVING_MODEL_...
Define a kubeflow pipeline.
166,513
import os from absl import logging from tfx import v1 as tfx from tfx.experimental.templates.penguin.pipeline import configs from tfx.experimental.templates.penguin.pipeline import pipeline PIPELINE_ROOT = os.path.join(OUTPUT_DIR, 'tfx_pipeline_output', configs.PIPELINE_NAME) METADATA_PATH ...
Define a pipeline.
166,514
import tensorflow_transform as tft from tfx.experimental.templates.penguin.models import features The provided code snippet includes necessary dependencies for implementing the `preprocessing_fn` function. Write a Python function `def preprocessing_fn(inputs)` to solve the following problem: tf.transform's callback fu...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,515
from typing import List from absl import logging import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils from tfx import v1 as tfx from tfx.experimental.templates.penguin.models import constants from tfx.experimental.templates.pen...
Train the model based on given args. Args: fn_args: Holds args used to train the model as name/value pairs.
166,516
import os from absl import logging from tfx import v1 as tfx from tfx.experimental.templates.taxi.pipeline import configs from tfx.experimental.templates.taxi.pipeline import pipeline PIPELINE_ROOT = os.path.join(OUTPUT_DIR, 'tfx_pipeline_output', configs.PIPELINE_NAME) SERVING_MODEL_DIR = ...
Define a kubeflow pipeline.
166,517
import os from absl import logging from tfx import v1 as tfx from tfx.experimental.templates.taxi.pipeline import configs from tfx.experimental.templates.taxi.pipeline import pipeline PIPELINE_ROOT = os.path.join(OUTPUT_DIR, 'tfx_pipeline_output', configs.PIPELINE_NAME) METADATA_PATH = os.p...
Define a local pipeline.
166,518
import os from absl import logging from tfx.experimental.templates.taxi.pipeline import configs from tfx.experimental.templates.taxi.pipeline import pipeline from tfx.orchestration.kubeflow.v2 import kubeflow_v2_dag_runner from tfx.proto import trainer_pb2 _PIPELINE_ROOT = os.path.join(_OUTPUT_DIR, 'tfx_pipeline_output...
Define a pipeline to be executed using Kubeflow V2 runner.
166,519
from absl import logging import tensorflow as tf from tensorflow import estimator as tf_estimator import tensorflow_model_analysis as tfma import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils from tfx import v1 as tfx from tfx.experimental.templates.taxi.models import features fr...
Small utility returning a record reader that can read gzip'ed files.
166,520
from absl import logging import tensorflow as tf from tensorflow import estimator as tf_estimator import tensorflow_model_analysis as tfma import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils from tfx import v1 as tfx from tfx.experimental.templates.taxi.models import features fr...
Train the model based on given args. Args: fn_args: Holds args used to train the model as name/value pairs.
166,521
import tensorflow as tf import tensorflow_transform as tft from tfx.experimental.templates.taxi.models import features def _fill_in_missing(x): """Replace missing values in a SparseTensor. Fills in missing values of `x` with '' or 0, and converts to a dense tensor. Args: x: A `SparseTensor` of rank 2. Its de...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,522
from absl import logging import tensorflow as tf import tensorflow_transform as tft from tfx.experimental.templates.taxi.models import features from tfx.experimental.templates.taxi.models.keras_model import constants from tfx_bsl.public import tfxio def _get_tf_examples_serving_signature(model, tf_transform_output): ...
Train the model based on given args. Args: fn_args: Holds args used to train the model as name/value pairs.
166,523
from typing import List The provided code snippet includes necessary dependencies for implementing the `vocabulary_name` function. Write a Python function `def vocabulary_name(key: str) -> str` to solve the following problem: Generate the name of the vocabulary feature from original name. Here is the function: def v...
Generate the name of the vocabulary feature from original name.
166,524
import collections from typing import Dict, List, Mapping, Set import tensorflow as tf from tfx.dsl.io import fileio from tfx.experimental.distributed_inference.graphdef_experiments.subgraph_partitioning import execution_spec def _get_graph_def(filepath: str) -> tf.compat.v1.GraphDef: graph_def = tf.compat.v1.GraphDe...
Gets the `GraphDef` protos from files. Args: graph_name_to_filepath: A mapping from graph names to filepaths. Each filepath points to a `GraphDef` proto in binary. Returns: A mapping from graph names to `GraphDef` protos.
166,525
import collections from typing import Dict, List, Mapping, Set import tensorflow as tf from tfx.dsl.io import fileio from tfx.experimental.distributed_inference.graphdef_experiments.subgraph_partitioning import execution_spec def _partition_one_graph( graph_def: tf.compat.v1.GraphDef, output_names: List[str]) -...
Partitions all the graphs. For each graph, the partitioning algorithm takes in the graph's `GraphDef` proto and output names, partitions the graph, and returns a list of ExecutionSpecs. Later, the beam_pipeline library can take in the ExecutionSpecs and execute the partitioned subgraphs. Args: graph_name_to_graph_def: ...
166,526
import tensorflow as tf tf.compat.v1.disable_eager_execution() def create_session(graph): return tf.compat.v1.Session( graph=graph, config=tf.compat.v1.ConfigProto(inter_op_parallelism_threads=8)) graph_a = tf.Graph() with graph_a.as_default(): table_a = tf.random.uniform(shape=[N, NDIMS], seed=10) i...
Mimics a remote op by numpy_function.
166,527
import tensorflow as tf tf.compat.v1.disable_eager_execution() def create_session(graph): return tf.compat.v1.Session( graph=graph, config=tf.compat.v1.ConfigProto(inter_op_parallelism_threads=8)) graph_b = tf.Graph() with graph_b.as_default(): ids_b2 = tf.compat.v1.placeholder(dtype=tf.int32, name='id...
Mimics another remote op.
166,528
import tensorflow as tf tf.compat.v1.disable_eager_execution() graph_a = tf.Graph() with graph_a.as_default(): table_a = tf.random.uniform(shape=[N, NDIMS], seed=10) ids_a = tf.compat.v1.placeholder(dtype=tf.int32, name='ids_a') result_a = tf.nn.embedding_lookup(table_a, ids_a) graph_b = tf.Graph() with graph_b....
null
166,529
import copy from typing import Any, Dict, Iterator, List, Mapping import apache_beam as beam import tensorflow as tf from tfx.experimental.distributed_inference.graphdef_experiments.subgraph_partitioning import execution_spec class _SubgraphLayerDoFn(beam.DoFn): """DoFn that executes one subgraph layer.""" def proc...
A PTransform that executes a graph. Each graph has a list of ExecutionSpecs, in which the order of the list represents the order of execution. An ExecutionSpec can either represent a subgraph layer or a remote op in a remote op layer. When executing a subgraph layer, we can load and execute the subgraph with a beam Par...
166,530
from absl import app from absl import flags import tensorflow_docs.api_generator as api_generator from tensorflow_docs.api_generator import generate_lib from tfx import v1 from tfx import version from tfx.utils import doc_controls from google.protobuf.reflection import GeneratedProtocolMessageType The provided code sn...
Removes "test" and "example" modules. These are not part of the public api. Args: path: A tuple of name parts forming the attribute-lookup path to this object. For `tf.keras.layers.Dense` path is: ("tf","keras","layers","Dense") parent: The parent object. children: A list of (name, value) pairs. The attributes of the p...
166,531
from absl import app from absl import flags import tensorflow_docs.api_generator as api_generator from tensorflow_docs.api_generator import generate_lib from tfx import v1 from tfx import version from tfx.utils import doc_controls from google.protobuf.reflection import GeneratedProtocolMessageType The provided code sn...
Remove all the proto inherited methods. Args: path: A tuple of name parts forming the attribute-lookup path to this object. For `tf.keras.layers.Dense` path is: ("tf","keras","layers","Dense") parent: The parent object. children: A list of (name, value) pairs. The attributes of the parent. Returns: A filtered list of c...
166,532
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def delete_run(ctx: Context, engine: str, run_id: str, endpoint: str, iap_cli...
null
166,533
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def _parse_runtime_parameters( runtime_parameters: Iterable[str]) -> Dict[str, str]: ""...
Command definition to create a pipeline run.
166,534
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def terminate_run(ctx: Context, engine: str, run_id: str, endpoint: str, ia...
Command definition to stop a run.
166,535
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def terminate_run(ctx: Context, engine: str, run_id: str, endpoint: str, ia...
Command definition to list all runs of a pipeline.
166,536
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def terminate_run(ctx: Context, engine: str, run_id: str, endpoint: str, ia...
Command definition to stop a run.
166,537
from typing import Iterable, Dict import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def terminate_run(ctx: Context, engine: str, run_id: str, endpoint: str, ia...
Command definition to delete a run.
166,538
import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import template_handler def template_group() -> None: pass
null
166,539
import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import template_handler def list_templates() -> None: click.echo('Available templates:') for model in template_handler.list_template(): click...
null
166,540
import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import template_handler class Context: """Context shared between all command groups. Attributes : flags_dict: A dictionary containing the fl...
Command definition to copy template to specified directory.
166,541
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def create_pipeline(ctx: Context, engine: str, pipeline_path: str, p...
null
166,542
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def _check_deprecated_image_build_flags(build_target_image=None, ...
Command definition to create a pipeline.
166,543
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def _check_deprecated_image_build_flags(build_target_image=None, ...
Command definition to update a pipeline.
166,544
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def create_pipeline(ctx: Context, engine: str, pipeline_path: str, p...
Command definition to delete a pipeline.
166,545
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def create_pipeline(ctx: Context, engine: str, pipeline_path: str, p...
Command definition to list pipelines.
166,546
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def _check_deprecated_image_build_flags(build_target_image=None, ...
Command definition to compile a pipeline.
166,547
import sys from typing import Optional import click from tfx.tools.cli import labels from tfx.tools.cli.cli_context import Context from tfx.tools.cli.cli_context import pass_context from tfx.tools.cli.handler import handler_factory def create_pipeline(ctx: Context, engine: str, pipeline_path: str, p...
Command definition to infer latest schema.
166,548
import click from tfx.tools.cli.commands.pipeline import pipeline_group from tfx.tools.cli.commands.run import run_group from tfx.tools.cli.commands.template import template_group def cli_group(): click.echo('CLI')
null
166,549
import functools import os import sys import time from typing import Any, Dict, Optional import click import kfp from tfx.orchestration.kubeflow import kubeflow_dag_runner from tfx.tools.cli import labels from tfx.tools.cli.container_builder import builder from tfx.tools.cli.handler import base_handler from tfx.tools.c...
null
166,550
import os import tempfile import typing from typing import Any, Callable, MutableMapping, Optional, Type from tfx.orchestration import pipeline as tfx_pipeline from tfx.orchestration import tfx_runner from tfx.orchestration.kubeflow import kubeflow_dag_runner from tfx.tools.cli.handler import dag_runner_patcher def _g...
null
166,551
def get_source_path(path: str) -> str: return path
null
166,552
from typing import Any, Dict, List, Mapping, MutableMapping, MutableSequence, Sequence, TypeVar import tfx.types from tfx.utils import pure_typing_utils from typing_extensions import ( # pylint: disable=g-multiple-import TypeGuard, # New in python 3.10 ) is_compatible = pure_typing_utils.is_compatible _TArtifact ...
Checks value is Sequence[T] where T is subclass of Artifact.
166,553
from typing import Any, Dict, List, Mapping, MutableMapping, MutableSequence, Sequence, TypeVar import tfx.types from tfx.utils import pure_typing_utils from typing_extensions import ( # pylint: disable=g-multiple-import TypeGuard, # New in python 3.10 ) is_compatible = pure_typing_utils.is_compatible def is_art...
null
166,554
from typing import Any, Dict, List, Mapping, MutableMapping, MutableSequence, Sequence, TypeVar import tfx.types from tfx.utils import pure_typing_utils from typing_extensions import ( # pylint: disable=g-multiple-import TypeGuard, # New in python 3.10 ) ArtifactMultiMap = MultiMap[str, tfx.types.Artifact] is_com...
Checks value is Sequence[Mapping[str, Sequence[Artifact]]] type.
166,555
import copy import logging import os from typing import Any, Dict, Optional from tfx.dsl.io import fileio The provided code snippet includes necessary dependencies for implementing the `get_logger` function. Write a Python function `def get_logger(config)` to solve the following problem: Create and configure a TFX-spe...
Create and configure a TFX-specific logger. Args: config: LoggingConfig class used to configure logger Returns: A logger that outputs to log_dir/log_file_name. Raises: RuntimeError: if log dir exists as a file.
166,556
import os import re import tempfile from typing import List, TypeVar, Iterable from tfx.dsl.io import fileio from google.protobuf import json_format from google.protobuf import text_format from google.protobuf.message import Message The provided code snippet includes necessary dependencies for implementing the `write_...
Writes a serialized tfrecord to file.
166,557
import os import re import tempfile from typing import List, TypeVar, Iterable from tfx.dsl.io import fileio from google.protobuf import json_format from google.protobuf import text_format from google.protobuf.message import Message ProtoMessage = TypeVar('ProtoMessage', bound=Message) The provided code snippet includ...
Parses a protobuf message from a JSON file and return itself.
166,558
import os import re import tempfile from typing import List, TypeVar, Iterable from tfx.dsl.io import fileio from google.protobuf import json_format from google.protobuf import text_format from google.protobuf.message import Message The provided code snippet includes necessary dependencies for implementing the `load_c...
Parse the first line of a csv file as column names.
166,559
import os import re import tempfile from typing import List, TypeVar, Iterable from tfx.dsl.io import fileio from google.protobuf import json_format from google.protobuf import text_format from google.protobuf.message import Message The provided code snippet includes necessary dependencies for implementing the `read_s...
Reads a string from a file.
166,560
import os import re import tempfile from typing import List, TypeVar, Iterable from tfx.dsl.io import fileio from google.protobuf import json_format from google.protobuf import text_format from google.protobuf.message import Message The provided code snippet includes necessary dependencies for implementing the `read_b...
Reads bytes from a file.
166,561
import functools import time from typing import Type from absl import logging The provided code snippet includes necessary dependencies for implementing the `retry` function. Write a Python function `def retry(max_retries: int = 3, delay_seconds: int = 1, expected_exception: Type[Exception] = Excep...
Function decorator to retry a function automatically. Example: from tfx.utils import retry @retry.retry() def some_fragile_func(): ... If `ignore_eventual_failure` is False, the last expected exception caught will raised from this function. If `ignore_eventual_failure` is True, no exception will raised and will return ...
166,562
import functools import inspect import warnings def _should_warn(func_or_class, warn_once=True): """Check whether to warn or not with side effect.""" if id(func_or_class) in _PRINTED_WARNING: return False if warn_once: _PRINTED_WARNING.add(id(func_or_class)) return True def _validate_callable(func): i...
Decorator marking function or method as deprecated. Note: this function does not currently support deprecation of classes. To perform such deprecation, decorate its constructor instead. Args: date: String date at which function will be removed, or None. instructions: Instructions on updating use of deprecated code. war...
166,563
import functools import inspect import warnings def _should_warn(func_or_class, warn_once=True): """Check whether to warn or not with side effect.""" if id(func_or_class) in _PRINTED_WARNING: return False if warn_once: _PRINTED_WARNING.add(id(func_or_class)) return True def _validate_callable(func): i...
Deprecates a symbol in favor of a renamed function or class. Args: deprecated_name: Fully qualified name of deprecated symbol. name: New symbol name. func_or_class: Non-deprecated function or class, to be used as alias. warn_once: Whether only one warning should be emitted for multiple calls to deprecated symbol. Retur...
166,564
def do_not_doc_in_subclasses(obj): return obj
null
166,565
def do_not_doc_inheritable(obj): return obj
null
166,566
def do_not_generate_docs(obj): return obj
null
166,567
EXTRA_DOCS = dict() The provided code snippet includes necessary dependencies for implementing the `documented` function. Write a Python function `def documented(obj, doc)` to solve the following problem: Adds a docstring to typealias by overriding the `__doc__` attribute. Note: Overriding `__doc__` is only possible a...
Adds a docstring to typealias by overriding the `__doc__` attribute. Note: Overriding `__doc__` is only possible after python 3.7. Args: obj: Typealias object that needs to be documented. doc: Docstring of the typealias. It should follow the standard pystyle docstring rules. Returns: Documented variables.
166,568
import subprocess import docker The provided code snippet includes necessary dependencies for implementing the `delete_image` function. Write a Python function `def delete_image(name: str, remote: bool = True)` to solve the following problem: Delete container image in local and remote registry. Here is the function: ...
Delete container image in local and remote registry.
166,569
def generate_monitoring_metrics( unused_test_stats_split, unused_baseline_stats_split, unused_split_pair, unused_span, unused_artifact, ) -> None: return
null
166,570
import os from typing import Optional, Tuple The provided code snippet includes necessary dependencies for implementing the `make_model_path` function. Write a Python function `def make_model_path(model_base_path: str, model_name: str, version: int) -> str` to solve the following problem: Make a TF...
Make a TFS-flavored model path. Args: model_base_path: A base path containing the directory of model_name. model_name: A name of the model. version: An integer version of the model. Returns: `{model_base_path}/{model_name}/{version}`.
166,571
import os from typing import Optional, Tuple def parse_model_path( model_path: str, expected_model_name: Optional[str] = None) -> Tuple[str, str, int]: """Parse model_path into parts of TFS flavor. Args: model_path: A TFS-flavored model path. expected_model_name: Expected model_name as defined from ...
Parse model_base_path from the TFS-flavored model path. Args: model_path: A TFS-flavored model path. Raises: ValueError: If model path is invalid (not TFS-flavored). Returns: model_base_path as defined from the module docstring.
166,572
import os import absl from tfx.dsl.io import fileio from tfx.types import artifact from tfx.types import artifact_utils from tfx.types import standard_artifacts from tfx.utils import io_utils from tfx.utils import path_constants def eval_model_dir(output_uri: str, is_old_artifact: bool = False) -> str: """Returns dir...
Returns final path to exported model for evaluation purpose.
166,573
import os import absl from tfx.dsl.io import fileio from tfx.types import artifact from tfx.types import artifact_utils from tfx.types import standard_artifacts from tfx.utils import io_utils from tfx.utils import path_constants def eval_model_dir(output_uri: str, is_old_artifact: bool = False) -> str: """Returns dir...
Returns directly for exported model depending on model_type.
166,574
import os import absl from tfx.dsl.io import fileio from tfx.types import artifact from tfx.types import artifact_utils from tfx.types import standard_artifacts from tfx.utils import io_utils from tfx.utils import path_constants The provided code snippet includes necessary dependencies for implementing the `stamped_mo...
Returns path for the stamped model.
166,575
import os import absl from tfx.dsl.io import fileio from tfx.types import artifact from tfx.types import artifact_utils from tfx.types import standard_artifacts from tfx.utils import io_utils from tfx.utils import path_constants The provided code snippet includes necessary dependencies for implementing the `warmup_fil...
Returns SavedModel Warmup file path. See https://www.tensorflow.org/tfx/serving/saved_model_warmup. This is a lexical operation, and does not guarantee the path is valid. Args: saved_model_path: A POSIX path to the TensorFlow SavedModel. Returns: A POSIX path to the SavedModel Warmup file.
166,576
import contextlib import functools import re import sys import threading from typing import Dict, List, Any, Callable from absl import logging from googleapiclient import http from tfx import version def make_labels_dict() -> Dict[str, str]: """Get all registered and system generated labels as a dict. Returns: ...
Make Beam arguments for common labels used in TFX pipelines. Returns: New Beam pipeline args with labels.
166,577
import contextlib import functools import re import sys import threading from typing import Dict, List, Any, Callable from absl import logging from googleapiclient import http from tfx import version def noop_telemetry( event_metric: Any ) -> Callable[[Callable[..., Any]], Callable[..., Any]]: del event_metric ...
null
166,578
import os import shutil import subprocess import sys import tempfile from typing import List import absl from tfx import dependencies from tfx import version from tfx.dsl.io import fileio from tfx.utils import io_utils def build_ephemeral_package() -> str: """Repackage current installation of TFX into a tfx_ephemeral...
Make beam arguments for TFX python dependencies, if latter was not set. When TFX executors are used with non-local beam runners (Dataflow, Flink, etc) the remote runner needs to have access to TFX executors. This function acts as a helper to provide TFX source package to Beam if user does not provide that through Beam ...
166,579
from tfx.utils import io_utils from tensorflow_metadata.proto.v0 import anomalies_pb2 The provided code snippet includes necessary dependencies for implementing the `write_anomalies` function. Write a Python function `def write_anomalies( filepath: str, anomalies: anomalies_pb2.Anomalies, ) -> None` to solve t...
Writes Anomalies to a binary proto file.
166,580
from typing import Dict, Iterable, List, Union from tfx import types from tfx.types import channel_utils from tfx.utils import deprecation_utils class Channel(types.Channel): pass None, 'tfx.utils.channel.as_channel has been renamed to ' 'tfx.types.channel_utils.as_channel as of TFX 0.14.0.') def as_channel(...
null
166,581
from typing import Dict, Iterable, List, Union from tfx import types from tfx.types import channel_utils from tfx.utils import deprecation_utils class Channel(types.Channel): pass None, 'tfx.utils.channel.as_channel has been renamed to ' 'tfx.types.channel_utils.as_channel as of TFX 0.14.0.') def unwrap_chan...
null
166,582
import abc from typing import Any The provided code snippet includes necessary dependencies for implementing the `abstract_property` function. Write a Python function `def abstract_property() -> Any` to solve the following problem: Returns an abstract property for use in an ABC abstract class. Here is the function: ...
Returns an abstract property for use in an ABC abstract class.
166,583
import datetime import enum import os import re import time from typing import Callable, Dict, List, Optional from absl import logging from kubernetes import client as k8s_client from kubernetes import config as k8s_config KFP_POD_NAME = 'KFP_POD_NAME' KFP_NAMESPACE = 'KFP_NAMESPACE' def is_inside_cluster() -> bool: ...
Whether current running environment is inside the KFP runtime.
166,584
import datetime import enum import os import re import time from typing import Callable, Dict, List, Optional from absl import logging from kubernetes import client as k8s_client from kubernetes import config as k8s_config KFP_NAMESPACE = 'KFP_NAMESPACE' The provided code snippet includes necessary dependencies for im...
Get kubernetes namespace for the KFP. Raises: RuntimeError: If KFP pod cannot be determined from the environment, i.e. this program is not running inside the KFP. Returns: The namespace of the KFP app, to which the pod this program is running on belongs.
166,585
import datetime import enum import os import re import time from typing import Callable, Dict, List, Optional from absl import logging from kubernetes import client as k8s_client from kubernetes import config as k8s_config KFP_POD_NAME = 'KFP_POD_NAME' KFP_NAMESPACE = 'KFP_NAMESPACE' The provided code snippet includes...
Get manifest of the KFP pod in which this program is running. Args: client: A kubernetes CoreV1Api client. Raises: RuntimeError: If KFP pod cannot be determined from the environment, i.e. this program is not running inside the KFP. Returns: The manifest of the pod this program is running on.
166,586
from typing import Any, Dict, Iterator, TypeVar, Optional from google.protobuf import any_pb2 from google.protobuf import descriptor_pb2 from google.protobuf import descriptor as descriptor_lib from google.protobuf import descriptor_pool from google.protobuf import json_format from google.protobuf import message from g...
Simple JSON Formatter wrapper for consistent formatting.
166,587
from typing import Any, Dict, Iterator, TypeVar, Optional from google.protobuf import any_pb2 from google.protobuf import descriptor_pb2 from google.protobuf import descriptor as descriptor_lib from google.protobuf import descriptor_pool from google.protobuf import json_format from google.protobuf import message from g...
Simple JSON Parser wrapper for consistent parsing.
166,588
import abc import functools import inspect import sys from typing import Any, Callable, Generic, Optional, TypeVar, Union, get_args, get_origin from tfx.utils import pure_typing_utils The provided code snippet includes necessary dependencies for implementing the `_is_subclass` function. Write a Python function `def _i...
issubclass that supports Union and Optional correctly.
166,589
import re from absl import logging from tfx import version _REGULAR_NIGHTLY_VERSION_PATTERN = re.compile(r'\d+\.\d+\.\d+(\.dev\d{8}){0,1}') _RC_VERSION_PATTERN = re.compile(r'\d+\.\d+\.\d+\-rc\d+') The provided code snippet includes necessary dependencies for implementing the `get_image_version` function. Write a Pyth...
Gets the version for image tag based on SDK version. Args: version_str: The SDK version. Returns: Version string representing the image version should be used. For offcially released version of TFX SDK, we'll align the SDK and the image versions; For 'dev' or customized versions we'll use the latest image version.
166,590
import pathway.internals as pw from pathway.internals import ColumnReference, Table from pathway.xpacks.llm.llms import prompt_chat_single_qa from pathway.xpacks.llm.prompts import prompt_qa def _query_chat_with_k_documents(chat: pw.UDF, k: int, t: pw.Table) -> pw.Table: limited_documents = t.select( pw.thi...
Function for querying LLM chat while providing increasing number of documents until an answer is found. Documents are taken from `documents` argument. Initially first `n_starting_documents` documents are embedded in the query. If the LLM chat fails to find an answer, the number of documents is multiplied by `factor` an...
166,591
import re import pathway as pw def prompt_citing_qa(query: str, docs: list[pw.Json]): context_pieces = [] for i, doc in enumerate(docs, 1): context_pieces.append(f"# Source {i}") context_pieces.append(doc["text"]) # type: ignore context_pieces.append("") context_str = "\n".join(co...
null
166,592
import re import pathway as pw def prompt_short_qa(query: str, docs: list[pw.Json]): context_pieces = [] for i, doc in enumerate(docs, 1): context_pieces.append(doc["text"]) context_pieces.append("") # type: ignore context_str = "\n".join(context_pieces) # type: ignore prompt = ( ...
null
166,593
import re import pathway as pw def prompt_summarize(text_list: list[str]): text = "\n".join(text_list) prompt = f"""Given a list of documents, summarize them in few sentences \ while preserving important points and entities. Documents: {text} Summary:""" return prompt
null
166,594
import re import pathway as pw def prompt_query_rewrite_hyde(query: str) -> str: prompt = f"""Write 4 responses to answer the given question with hypothetical data. Try to include as many key details as possible. Question: `{query}`. Responses:""" return prompt
null
166,595
import re import pathway as pw def prompt_query_rewrite(query: str, *additional_args: str) -> str: prompt = f"""Given a question that will be used to retrieve similar documents for RAG application. Rewrite question to be better usable in retrieval search. Use important entities, words that may be related t...
null
166,596
import re import pathway as pw def parse_cited_response(response_text, docs): cited_docs = [ int(cite[1:-1]) - 1 for cite in set(re.findall("\[\d+\]", response_text)) # noqa: W605 ] start_index = response_text.find("*") + 1 end_index = response_text.find("*", start_index) citation...
null
166,597
import unicodedata import pathway as pw The provided code snippet includes necessary dependencies for implementing the `null_splitter` function. Write a Python function `def null_splitter(txt: str) -> list[tuple[str, dict]]` to solve the following problem: A splitter which returns its argument as one long text ith nul...
A splitter which returns its argument as one long text ith null metadata. Args: txt: text to be split Returns: list of pairs: chunk text and metadata. The null splitter always return a list of length one containing the full text and empty metadata.
166,598
import unicodedata import pathway as pw The provided code snippet includes necessary dependencies for implementing the `_normalize_unicode` function. Write a Python function `def _normalize_unicode(text: str)` to solve the following problem: Get rid of ligatures Here is the function: def _normalize_unicode(text: str...
Get rid of ligatures
166,599
import asyncio import functools import json import logging import threading from collections.abc import Callable, Coroutine from typing import TYPE_CHECKING import jmespath import numpy as np import requests import pathway as pw import pathway.xpacks.llm.parsers import pathway.xpacks.llm.splitters from pathway.stdlib.m...
null
166,600
import asyncio import functools import json import logging import threading from collections.abc import Callable, Coroutine from typing import TYPE_CHECKING import jmespath import numpy as np import requests import pathway as pw import pathway.xpacks.llm.parsers import pathway.xpacks.llm.splitters from pathway.stdlib.m...
null
166,601
import asyncio import openai as openai_mod import pathway as pw from pathway.internals import udfs async def _safe_aclose(self): try: await self.aclose() except RuntimeError: pass The provided code snippet includes necessary dependencies for implementing the `_mokeypatch_openai_async` function....
Be more permissive on errors happening in httpx loop closing. Without this patch, many runtime errors appear while the server is running in a thread. The errors can be ignored, but look scary.
166,602
import os import subprocess import sys import uuid from typing import NoReturn import click import pathway as pw def cli() -> None: pass
null
166,603
import os import subprocess import sys import uuid from typing import NoReturn import click import pathway as pw def spawn_program(threads, processes, first_port, program, arguments, env_base): processes_str = plural(processes, "process", "processes") workers_str = plural(processes * threads, "total worker", "t...
null
166,604
import os import subprocess import sys import uuid from typing import NoReturn import click import pathway as pw def spawn_program(threads, processes, first_port, program, arguments, env_base): def replay( threads, processes, first_port, record_path, mode, continue_after_replay, program, ...
null
166,605
from __future__ import annotations from collections.abc import Callable import pathway.internals as pw def classifier_accuracy(predicted_labels, exact_labels): pw.universes.promise_is_subset_of(predicted_labels, exact_labels) comparative_results = predicted_labels.select( predicted_label=predicted_labe...
null
166,606
from __future__ import annotations from collections.abc import Callable import pathway.internals as pw The provided code snippet includes necessary dependencies for implementing the `_predict_asof_now` function. Write a Python function `def _predict_asof_now( prediction_function: Callable[..., pw.Table], *quer...
A helper function used to predict answers to queries without updating them in the future. It passes a query and its forgetting counterpart through the prediction function. Parameters: prediction_function: A function that is called with transformed column reference `query`. queries: References to a column/columns with q...
166,607
from __future__ import annotations import math from collections.abc import Callable from enum import IntEnum, auto from typing import Any import pathway.internals as pw from pathway.internals.helpers import StableSet def _tokenize(obj: Any) -> Any: return str(obj).split()
null
166,608
from __future__ import annotations import math from collections.abc import Callable from enum import IntEnum, auto from typing import Any import pathway.internals as pw from pathway.internals.helpers import StableSet def _letters(obj: Any) -> Any: return [c.lower() for c in str(obj) if c.isalnum()]
null
166,609
from __future__ import annotations import math from collections.abc import Callable from enum import IntEnum, auto from typing import Any import pathway.internals as pw from pathway.internals.helpers import StableSet def _discrete_weight(cnt: float) -> float: if cnt == 0: return 0.0 else: retur...
null
166,610
from __future__ import annotations import math from collections.abc import Callable from enum import IntEnum, auto from typing import Any import pathway.internals as pw from pathway.internals.helpers import StableSet def _discrete_logweight(cnt: float) -> float: if cnt == 0: return 0.0 else: re...
null
166,611
from __future__ import annotations import math from collections.abc import Callable from enum import IntEnum, auto from typing import Any import pathway.internals as pw from pathway.internals.helpers import StableSet def _none(cnt: float) -> float: return cnt
null