SFDO-Tooling / Snowfakery

A tool for generating fake data that has relations between tables.
BSD 3-Clause "New" or "Revised" License
143 stars 32 forks source link

Faker provider and associated arguments not being captured in snowfakery versions 2.0 and above ( currently explicitly pointing to 1.12 for expected behavior ) #537

Closed jdschleicher closed 2 years ago

jdschleicher commented 3 years ago

reproduced in:

Hi! We have been using snowfakery starting with version 1.12. We have been working on some poc's for the different field types we were looking to mock within our salesforce instances. When snowfakery jumped to version 2.0 and higher it seemed like some of the faker providers and associated functions were no longer taking in the parameters we were providing. We also saw some runtime errors stating the aliases we were trying that work in 1.12 no longer worked in 2.0 and above. Below are some examples along with our poc yml file.

We have been able to explicitly point to version 1.12 and things have been working as expected but we aren't sure if there is some fundamental approach or piece we are missing on our end that prevents versions 2.0 and above to work as expected with some of the faker providers. Any direction is greatly appreciated!

Below is our poc yml.

- object: SeededRecord__c  
  nickname: SeededRecordRoot  
  count: 1000  
  fields:  
    checkbox1__c:  
        random_choice:
          - 'true'
          - 'false'
    currency1__c:
      fake: pyfloat
    date1__c:
      fake: date
    datetime1__c: ${{ fake.date(pattern='%Y-%m-%d') }}T${{ fake.pyint(min_value=1,max_value=20) }}${{ fake.time(pattern='%H:%M:%S') }}Z
    picklist1__c:
      random_choice:
        - 'bravo'
        - 'alpha'
        - 'charlie'
        - 'delta'
        - 'echo'
        - 'foxtrot'
    dependentpicklist1__c:
      if:
        - choice:
            when: ${{picklist1__c=='alpha'}}
            pick:
              random_choice:
                - sierra
        - choice:
            when: ${{picklist1__c=='bravo'}}
            pick:
              random_choice:
                - sierra
                - tango
        - choice:
            when: ${{picklist1__c=='charlie'}}
            pick:
              random_choice:
                - sierra
                - tango
                - uniform
                - victor
        - choice:
            when: ${{picklist1__c=='delta'}}
            pick:
              random_choice:
                - sierra
                - tango
                - uniform
                - victor
        - choice:
            when: ${{picklist1__c=='echo'}}
            pick:
              random_choice:
                - sierra
                - tango
        - choice:
            when: ${{picklist1__c=='foxtrot'}}
            pick:
              random_choice:
                - sierra
    email1__c:
      fake: ascii_safe_email
    formulafield1__c:
      fake: first_name
    formulafield2__c:
      fake: last_name
    geolocation1__latitude__s:
      fake: latitude
    geolocation1__longitude__s:
      fake: longitude
    number1__c: ${{fake.pyint(min_value=0,max_value=1000000)}}
    percent1__c: ${{fake.pyint(min_value=0,max_value=100)}}
    phone1__c:
      fake: phone_number
    picklistmultiselect1__c: ${{ ';'.join(( fake.random_sample( elements=('alpha','bravo','charlie','delta','echo','foxtrot') ) )) }}
    text1__c:
      fake: sentence
    textencrypted1__c:
      fake: credit_card_number
    textarea1__c:
      fake: paragraph
    textarealong1__c:
      fake: paragraph
    textarearich1__c:
      fake: paragraph
    time1__c:
      fake: time
    url1__c:
      fake: url
prescod commented 2 years ago

Hello @jdschleicher !

I set up a new venv like this:

$ python -m venv sf-2.2.1
$ cd sf-2.2.1
$ source bin/activate
$ pip install snowfakery

Then I ran your recipe

snowfakery /tmp/faker.recipe.yml

And I see results like this:

SeededRecord__c(id=998, checkbox1__c=false, currency1__c=20371.3964781705, date1__c=1995-09-15, datetime1__c=1987-03-20T1218:11:49Z, picklist1__c=alpha, dependentpicklist1__c=sierra, email1__c=josephrobertson@example.net, formulafield1__c=Arthur, formulafield2__c=Porter, geolocation1__latitude__s=41.260816, geolocation1__longitude__s=48.224890, number1__c=127080, percent1__c=29, phone1__c=(077)077-7033x3589, picklistmultiselect1__c=delta;echo;foxtrot;alpha, text1__c=End section minute those increase likely eat., textencrypted1__c=4978711891849281659, textarea1__c=Now kid up mean purpose myself. Including rise population show each area. Human letter anything eight and., textarealong1__c=Last game yard today. Computer change fill industry left thus discover. Phone we candidate task at others remain., textarearich1__c=Evening them movement herself theory build statement itself. Far stock garden involve town., time1__c=20:08:02, url1__c=http://www.calderon.org/)
SeededRecord__c(id=999, checkbox1__c=false, currency1__c=930.13863630753, date1__c=1983-08-17, datetime1__c=1970-08-26T923:51:35Z, picklist1__c=foxtrot, dependentpicklist1__c=sierra, email1__c=stacy36@example.org, formulafield1__c=Nathaniel, formulafield2__c=Sheppard, geolocation1__latitude__s=-68.924191, geolocation1__longitude__s=-119.871746, number1__c=605322, percent1__c=43, phone1__c=(493)789-8925x543, picklistmultiselect1__c=charlie;foxtrot;alpha;delta;echo, text1__c=President accept there pay life., textencrypted1__c=377979658101373, textarea1__c=Peace much sense rate resource. Be indicate with each realize even. Agreement oil alone wear edge happy., textarealong1__c=Now cell management conference. Attack avoid pick group what feel. Worry believe economic boy., textarearich1__c=Often animal issue especially. Result talk describe much product subject she. Poor note require take she., time1__c=23:09:12, url1__c=http://richmond.com/)
SeededRecord__c(id=1000, checkbox1__c=false, currency1__c=-2770500223.88709, date1__c=1994-12-22, datetime1__c=2003-06-08T1914:59:38Z, picklist1__c=echo, dependentpicklist1__c=sierra, email1__c=claudia68@example.net, formulafield1__c=Ruben, formulafield2__c=Edwards, geolocation1__latitude__s=76.1468155, geolocation1__longitude__s=101.237264, number1__c=623320, percent1__c=77, phone1__c=+1-101-884-5832x437, picklistmultiselect1__c=bravo;charlie;alpha;foxtrot;delta, text1__c=Traditional manage leave clear manager yeah century., textencrypted1__c=180019245370608, textarea1__c=Project institution guy financial method throw. Rather subject military catch throw., textarealong1__c=Movement would land mother hit enjoy. Determine hour performance minute company meet actually meeting., textarearich1__c=Partner word fly particular edge type character. Factor current sort production cut., time1__c=19:29:10, url1__c=https://shields.biz/)

Can you clarify which parts are not working for you?

jdschleicher commented 2 years ago

thank you @prescod !!!

soooooooooooooo.......

i have been peppering my machine with different pip and python version updates, installs, uninstalls in troubleshooting both snowfakery and robot framework. Every time I did a fresh install of python 10.0 and tried "pip install snowfakery" I would get "wheel wasn't able to complete" ( This isn't the exact message and I lost my terminal context to capture it). The first error that lead to the wheel not being ale to be setup showed as:

error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

I followed that link, tried the toolds update along with a few other stackoverflow suggestions and no luck.

I eventually gave up on python 3.10.0 because I had some things working with robotframework before upgrading to 10.0 that no longer worked. After uninstalling 3.10.0 and making sure all lingering python directories were removed from my AppData directories and paths removed from environment variables, I then installed python 3.9.9 and so far everything is working as expected and as you played out above.

Thank you for your help! This is either poor discipline in my handling of python/pip versions or something specific with my machine and python 10.0

image

davisagli commented 2 years ago

@jdschleicher The context here is that some of CumulusCI's Python package dependencies include portions written in C, so they need to be compiled. If they publish binary wheels for Windows on PyPI (the Python package index), then they can be installed even if you don't have a compiler. But binary wheels are linked to a specific version of Python, so when a new version of Python is released, it can take some time until all our dependencies have published updated binary wheels for the new Python.

So basically the explanation for your troubles with Python 3.10 is "it's too early to expect that to work." Sorry about that. We've recently updated the Windows install docs for CumulusCI to recommend a specific Python version.

jdschleicher commented 2 years ago

all good @davisagli !!! that makes total sense and I'll definitely be mindful next time if I get the urge to go all out upgrading again lol. What all started this was a documentation effort, I cleared out my system to make sure I had all steps covered for documentation to get things up and running with snowfakery for new teammates and saw the python version jumped and still went for it. Thanks again!