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 #2598

Merged
merged 9 commits into from
Aug 13, 2024

Conversation

edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Aug 9, 2024

Copy of #2578 where I can push, since that one was created from a protected branch.


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

@edgarrmondragon edgarrmondragon added this to the v0.40.0 milestone Aug 9, 2024
Copy link

codspeed-hq bot commented Aug 9, 2024

CodSpeed Performance Report

Merging #2598 will not alter performance

Comparing 2578-copy (142d091) with main (be349ac)

Summary

✅ 6 untouched benchmarks

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.62%. Comparing base (be349ac) to head (142d091).
Report is 118 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2598      +/-   ##
==========================================
- Coverage   89.66%   89.62%   -0.05%     
==========================================
  Files          58       58              
  Lines        4817     4817              
  Branches      944      944              
==========================================
- Hits         4319     4317       -2     
- Misses        347      349       +2     
  Partials      151      151              

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

@edgarrmondragon edgarrmondragon marked this pull request as ready for review August 13, 2024 20:32
@edgarrmondragon edgarrmondragon requested review from a team as code owners August 13, 2024 20:32
@ReubenFrankel
Copy link
Contributor

Maybe I'm missing something, but could this not have been achieved already using seed_instance?

stream_maps:
  customers:
    # will always generate the same value for the same seed
    first_name: fake.seed_instance(_['first_name']) or fake.first_name()
faker_config:
  # IMPORTANT: `fake` and `Faker` names are only available if faker_config is defined.
  locale: en_US

https://faker.readthedocs.io/en/master/index.html#seeding-the-generator

@edgarrmondragon
Copy link
Collaborator Author

Oh, right

Each generator can also be switched to use its own instance of random.Random, separated from the shared one, by using the seed_instance() method, which acts the same way.

If that's the case, we should deprecate Faker and recommend seed_instance().

Thoughts @Mac-lp3?

@Mac-lp3
Copy link
Contributor

Mac-lp3 commented Sep 15, 2024 via email

@Mac-lp3
Copy link
Contributor

Mac-lp3 commented Sep 16, 2024

@ReubenFrankel you are 100% correct, you can accomplish the exact same thing with fake.seed_instance(), so adding Fake was not necessary 🤦

@edgarrmondragon, so it looks like the mapper.py changes can be reverted... i think it would at least be handy to keep the updated docs that explains how to get consistent hashing and why you may want to. Of course, it just needs to be updated again to use fake.seed_instance() rather than Fake.seed(), which I don't mind fixing since its my mistake...

Should I just submit a new PR for that? If so, should it just be for the documentation changes, or should it also include reverting mapper.py?

@edgarrmondragon
Copy link
Collaborator Author

@ReubenFrankel you are 100% correct, you can accomplish the exact same thing with fake.seed_instance(), so adding Fake was not necessary 🤦

@edgarrmondragon, so it looks like the mapper.py changes can be reverted... i think it would at least be handy to keep the updated docs that explains how to get consistent hashing and why you may want to. Of course, it just needs to be updated again to use fake.seed_instance() rather than Fake.seed(), which I don't mind fixing since its my mistake...

Should I just submit a new PR for that? If so, should it just be for the documentation changes, or should it also include reverting mapper.py?

Thanks for the offer @Mac-lp3! Can you take a look at #2670 and comment if you think something's off or missing?

@Mac-lp3
Copy link
Contributor

Mac-lp3 commented Sep 16, 2024

@edgarrmondragon took a look and looks good to me!

@ReubenFrankel
Copy link
Contributor

@Mac-lp3 FWIW I think the docs change was super helpful! 😅

@edgarrmondragon
Copy link
Collaborator Author

Thanks both!

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

Successfully merging this pull request may close these issues.

3 participants