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

Mapping file generation super-powers #290

Merged
merged 5 commits into from
Mar 26, 2021
Merged

Mapping file generation super-powers #290

merged 5 commits into from
Mar 26, 2021

Conversation

prescod
Copy link
Contributor

@prescod prescod commented Mar 17, 2021

  1. Allow users to inject load declarations into generated mapping file.
  2. Allow users to order mapping file declarations
  3. Auto-inject "after:" declarations where appropriate.

(the description below is the vision...not every detail is implemented yet)

Still needs CCI side, documentation and tests.

Snowfakery and Mapping Files

CumulusCI's bulk loader depends on a mapping file to determine the load order of data.

Snowfakery generates this mapping file automatically in the generate_and_load_from_yaml job. Occasionally you may need to inject some additional information into the load. For example, you might want to change which API or processing mode to use (REST API, BULK API, Bulk Serial, Bulk Parallel). Or you might want to enforce a certain load order.

You can now do that by specifying a "recipe.load.yml" file to go with your recipe file. The --load-yml command line argument allows that and there is also a file naming convention which does it automatically (TBD).

Here are the declarations you may put into the "recipe.load.yml".

  • sf_object: Contact
    bulk_mode: serial # same as specifying bulk_mode in mapping file

  • sf_object: Contact
    load_after: Opportunity # load contacts after opportunities for some reasoon

  • sf_object: Account # same as specifying api in mapping file
    api: rest

1. Allow users to inject load declarations into generated mapping file.
2. Allow users to order mapping file declarations
3. Auto-inject "after:" declarations where appropriate.

Still needs documentation and test.
@TheBitShepherd TheBitShepherd self-requested a review March 18, 2021 16:18
@davisagli
Copy link
Contributor

I think the feature makes sense, but why a separate file instead of including these hints somewhere in the main recipe that the mapping generator knows to look for? Do you anticipate a need to use different sets of hints with the same recipe?

@prescod
Copy link
Contributor Author

prescod commented Mar 19, 2021

I think the feature makes sense, but why a separate file instead of including these hints somewhere in the main recipe that the mapping generator knows to look for? Do you anticipate a need to use different sets of hints with the same recipe?

Yes, I do anticipate that e.g. the standard NPSP recipe might work on your org but automation you've installed might make the load order unique to your org.

Or conversely (and perhaps more commonly!) the standard NPSP load file might work but you want to add a custom field to the recipe and therefore create your own.

In the not too distant future I could also imagine you sharing the files between Snowfakery data loads and CCI SQL loads instead of using the succinct Snowfakery format in one place and the verbose and unwieldy mapping file format in the other.

And then in the distant future, perhaps there is some centralized management of them analogous to TypeShed, DefinitelyTyped, SchemaStore.org etc. (or maybe that won't be useful enough)

Also: any syntax for adding CCI-specific information to recipe files would need to be either CCI-specfic syntax or a pragma syntax. I'd rather not muddy the recipe format with that.

@prescod prescod marked this pull request as ready for review March 25, 2021 11:56
@prescod prescod changed the title WIP: Mapping file generation super-powers Mapping file generation super-powers Mar 25, 2021
from pysnooper import snoop


@snoop()
Copy link
Contributor

@TheBitShepherd TheBitShepherd Mar 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL: pysnooper!

Copy link
Contributor

@TheBitShepherd TheBitShepherd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the changes since we reviewed this together. All looks good. I really appreciated the addition of the docstrings!

@prescod prescod merged commit 169b887 into main Mar 26, 2021
@prescod prescod deleted the feature/mapping-mixins branch March 26, 2021 16:49
@davisagli
Copy link
Contributor

Still needs docs, right?

@prescod
Copy link
Contributor Author

prescod commented Mar 26, 2021 via email

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.

3 participants