Data generator from lists
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start by reviewing the existing anonymizer_paths configuration and how current data packs are discovered. Compare the proposed YAML/JSON/PHP datasource structure with the existing fr-fr pack and define the unresolved loading, expression, and fixed-column behavior. Done means the format and distribution mechanism are agreed and implemented with coverage for the described datasource cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In order to easier anonymizers creation, we sometime talked about allowing the user to provide sample data as plain old text, json or yaml files.
While thinking about this, and due to the fact I wrote the Faker integration not so long ago, I noticed that we could generate much more data by providing a way for the data sources to provide a set of expressions that mixes its own data with other data sources data. Faker does it in a way, using plain old PHP code, which differs for each language.
I ended up using my imagination to a structure spec for such data source and expressions definition.
Here it is, in YAML (please not that YAML is not a requirement, it's a simple data structure that can be expressed in many languages, YAML is one of the easiest for non IT people I guess, but JSON, PHP arrays would do the trick as well.
Without further ado, here it is:
fr-fr:
# A datasource is basically an item list in which data will be
# pulled randomly.
car_type:
data: [sedan, hatchback, limousine, SUV, crossover]
# Moreover, the data can be in an additional file, relative
# to this file path, which is the recommended way to easier
# maintenance.
galaxy_name:
# File can be either:
# - If JSON, it must contain a single array `["foo","bar"]`
# - if TXT, then one line per item.
data: "./resources/galaxy-name.txt"
# Additionally, a datasource can hold one or more "expressions".
# If so, data is ignored, but expressions are selected randomly
# for each generated line, and executed.
# An expression is a very simple string, containing:
# - "{{foo}}" where "foo" is a datasource name: randomly takes
# one value out the given datasource name. It can refer self
# case in which data will be fetched for the "data" list.
# - "[-12;+123]" will extract a random integer between bounds.
# - "(foo|bar)" will output randomly either "foo" or "bar"
# - Everything else is just raw text.
# Simple exemple:
firstname:
data: [Jules, Nolwenn, Roberto, Jessica]
expressions:
- "{{firstname}}"
- "{{firstname}}-{{firstname}}"
# Datasources may be consistued of only expressions, without
# the data list, case in which it must pull data from other
# datasources:
lastname:
data: "./resources/lastname.txt"
expression:
- "{{single_lastname}}"
- "{{single_lastname}}-{{single_lastname}}"
- "{{single_lastname}} {{single_lastname}}"
# Multicolumn datasources can be "fixed", in case each item will be
# restitued as-is, without modification. This is useful when working
# with data that must remain consistent.
# You must specify the "type: fixed" property when doing this,
# otherwise columns will be mixed up when generating sample.
# Column names are mandatory.
# In this case, data file structure is:
# - If JSON, it must contain a single array `[{"a": "b"},{"a":"d"}]`
# - if TXT or CSV, then it's a CSV, use comas as separators.
# In all cases, multicolumn datasources can use any number of "invariant"
# columns (fixed value for all items generated by the sample).
# Fixed datasources cannot hold expressions.
address_fixed:
columns: [street, city, country]
type: fixed
invariant:
country: France
data:
- {street: 'rue des fleurs', city: 'Donaldville
- {street: 'rue de la Bastille', city: 'Paris'}
# For example purpose, we choose to discrimate an address an a set
# of datasources whose purpose is to help generating more random
# addresses.
address_street_type:
data: [rue, avenue, impasse]
address_street:
data: ["des fleurs", "de l'espoir", "des marroniers"]
expressions:
- "[1-128] {{address_street_type}} {{address_street}}"
address_city:
data: [Nantes, Paris, Lyon]
# Multicolumn datasources are per default "mixed", which can be
# expressed using the "type: mixed" property, or by not specifying
# the entry.
# In this case, it must use expressions to randomly fetch data
# from other datasources.
address:
columns: [street, city, country]
invariant:
country: France
expressions:
street: "{{address_street}}"
city: "{{address_city}}"
This very simple spec could allow great flexibility for creating new packs, ease of maintenance, moreover allow non-IT people, or people unfamiliar with PHP to contribute or create their own data packs.
This example covers a lot of the existing fr-fr pack. For creating a new pack, a user should:
- Give a datasource definition file (the example above), which can be:
- YAML: the example above,
- JSON: same structure, but JSON,
- PHP: using the builder pattern, we should provide an API for datasource definition.
- Raw primary data for the datasource as text files.
And that's it.
For distribution:
- If using composer, then add the
"type": "db-tools-bundle-pack"in composer.json file, and use a fixed name for the datasource index file, such asanonymizer-datasource.[yaml|json|php]. - Or if not, search for those files using the
anonymizer_pathsconfiguration variable (existing).
- Lingua principale
- PHP
- Stelle
- 235
- Fork
- 17
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di makinacorpus/DbToolsBundle
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
makinacorpus/DbToolsBundle#259 ·
-
Command-line option --config is not applied when creating database connections in standalone modeAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
makinacorpus/DbToolsBundle#260 ·
-
Laravel 12.0 & 13.0 supportForse di nuovo libera @Lonnytunes l’ha presa 169 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement good first issue
makinacorpus/DbToolsBundle#254 · 6 commenti · 1 assegnatario ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
makinacorpus/DbToolsBundle#252 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
makinacorpus/DbToolsBundle#237 ·
Tutte le issue di makinacorpus/DbToolsBundle
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
taskforcesh/bullmq#5238 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itForse già presa @bfs2021 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Automattic/jetpack#55517 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
area/import type/enhancement when/later
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno