Skip to content

Latest commit

 

History

History
102 lines (79 loc) · 4.83 KB

mapping_files.rst

File metadata and controls

102 lines (79 loc) · 4.83 KB

Mapping Files

PyPads using the concept of mapping files to track which functions should be logged. These files are written in YAML. YAML (YAML Ain't A Markup Language) is a human readable data serialization language. YAML has features such as comments and anchors these features make it desirable.

The mapping file can be divided broadly into different parts like metadata, fragments and mappings. Each section is explained in detail below. Following excerpts show possible mapping files. While the keras file uses implicit syntax for the path matchers marked by a prepending :, the sklearn version depicts how to use YAML typing with !!python/pPath, !!python/rSeg or !!python/pSeg.

files/keras.2_3_1.yml

files/sklearn_0_19_1.yml

metadata:
  author: "Thomas Weißgerber"
  version: "0.1.0"
  library:
    name: "sklearn"
    version: "0.19.1"
fragments:
  default_model:
    .__init__:
      events: "pypads_init"
    .{re:(fit|.fit_predict|fit_transform)$}:
      events: "pypads_fit"

Concepts

PyPads mapping files contain keys called concepts. When creating a main key in the mappings file, it could be anything such as a metric, a dataset, splitting strategy, an algorithm and so forth. The concepts key present within the main key links the main key to previously determined categories such as metric, dataset or algorithm to name a few. This helps PyPads recognize what type the main key is and how to process it.

Notations

function groups that should trigger specific events. Here in the below given example, we hook all functions in sklearn.metrics.classification to "pypads_metric". We also inform PyPads that all functions of this form are an instance of sklearn provided metrics using the concepts key.

mappings:
  sklearn:
    .metrics.classification.{re:.*}:
       data:
         concepts: ["Sklearn provided metric"]
         events: "pypads_metric"

Adding a new mapping file

When a user wants to add their own mapping file, they have to follow the following steps # Create a YAML mapping file in the path pypads/bindings/resources/mapping with the appropriate name and version number # Add a metadata part containing information about the author, version of the mapping file and library # Add fragments if a general function name is present. You can use regex to specify the patterns # Add mappings for metrics, datasets etc is they are present # PyPads will pick up the information when it is restarted.