Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mappers): Stream map expressions now have access to the Faker class, rather than just a faker instance #2578

Closed
wants to merge 7 commits into from

Conversation

Mac-lp3
Copy link
Contributor

@Mac-lp3 Mac-lp3 commented Jul 30, 2024

I made a post in the discussions about my motivation for this.

Note the Faker lib provides two ways to accomplish this:

  1. How it is done in this PR
from faker import Faker
Faker.seed('something')
faker = Faker()

The meltano mapper config would then look something like this:

stream_maps:
    "*":
        FirstName: Faker.seed('something') or fake.first_name() # note lib not instance
    faker_config:
        seed: 'something' # kind of redundant in this example, but hey, still works
  1. Create your faker instance using the Faker.factory.
from faker.factory import Factory
Faker = Factory.create
fake = Faker()
fake.seed(0)

With this approach, the meltano mapper config would have looked something like this:

stream_maps:
    "*":
        FirstName: faker.seed('something') or fake.first_name() # note instance not lib
    faker_config:
        seed: 'something'

Option 2 is actually what the faker docs recommend.

Unfortunately, option 2 does not allow for multiple locales. Given that, I thought it best to go with option 1, rather than breaking other people's code.


📚 Documentation preview 📚: https://meltano-sdk--2578.org.readthedocs.build/en/2578/

…pper expressions (provided a faker config is found).
Copy link

codspeed-hq bot commented Jul 30, 2024

CodSpeed Performance Report

Merging #2578 will not alter performance

Comparing Mac-lp3:main (cc85615) with main (87d78b3)

Summary

✅ 6 untouched benchmarks

@Mac-lp3 Mac-lp3 changed the title feat(mapper): expressions now have access to the Faker libary, rather than just faker instance feat(mappers): expressions now have access to the Faker libary, rather than just faker instance Jul 30, 2024
@edgarrmondragon
Copy link
Collaborator

Hi @Mac-lp3, thanks for the PR!

I've read through your post in #2537 also the docs in and https://faker.readthedocs.io/en/master/fakerclass.html#upgrade-guide and I think this makes and is the easiest way to add support for reproducible masking.

I think it's worth documenting the new object that'll be available in the stream map context. Wdyt?

Copy link

codecov bot commented Jul 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.47%. Comparing base (87d78b3) to head (cc85615).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2578   +/-   ##
=======================================
  Coverage   89.47%   89.47%           
=======================================
  Files          58       58           
  Lines        4798     4798           
  Branches      936      936           
=======================================
  Hits         4293     4293           
  Misses        352      352           
  Partials      153      153           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mac-lp3 Mac-lp3 requested review from a team as code owners July 30, 2024 22:41
@Mac-lp3
Copy link
Contributor Author

Mac-lp3 commented Jul 30, 2024

Hi again @edgarrmondragon,

Docs are now updated.

I added Faker the list of built-in variables. I also added a section about how to use faker and the different approaches.

Hope this is up to standard, but just lmk if not 🤝

@edgarrmondragon edgarrmondragon changed the title feat(mappers): expressions now have access to the Faker libary, rather than just faker instance feat(mappers): Stream map expressions now have access to the Faker class, rather than just a faker instance Aug 6, 2024
@edgarrmondragon edgarrmondragon added this to the v0.40.0 milestone Aug 6, 2024
@edgarrmondragon
Copy link
Collaborator

Superseded by #2598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants