Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

franken gen #93

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

franken gen #93

wants to merge 9 commits into from

Conversation

mitchkyle-reify
Copy link
Contributor

@mitchkyle-reify mitchkyle-reify commented Oct 19, 2022

franken-gen is an iteration on spec-gen, schemas and queries from spec-gen are fully backwards compatible.

Features:

  • Add support for malli and test.check.generators.
  • Dynamically load builtin generation functions. (Bring your own dependencies, only use what you need)
  • Add ability to override the entity generation in the query
  • In the schema and queries, rename :spec-gen to :set to make the intention more clear. the :spec-gen key is still accepted for backwards compatibility
  • Added a convenient way to insert entities after they've been generated without having to re-visit.

What do we think of this approach? I know it changes the intentions for visiting a bit but I think it makes using specmonstah for generating data more intuitive. Regarding the name, I called it franken-gen because it stitches together different generation mechanisms, and it leans away from the "spec" and into the "monstah" motif. I am open to alternatives though.

PS: Some changes that are in master related to the release are included in this PR.

mitchkyle-reify and others added 4 commits October 7, 2022 13:58
`franken-gen` is an interation on `spec-gen`, schemas and queries from spec-gen
are fully backwards compatible.

- Add support for malli and test.check.generators.

- Dynamically load builtin generation functions. (if you don't need it then
you don't have to include the dependency for it.)

- Add ability to override the entity generation in the query

- Regarding the name, I called it `franken-gen` because it stitches
together different generation mechanisms, and it leans away from the
"spec" and into the "monstah" motif. I am open to alternatives though.
@flyingmachine
Copy link
Contributor

I haven't looked at this in detail yet but this but from the description most of these are supported in the work I've done at https://github.com/donut-power/datapotato . I think only Dynamically load builtin generation functions might not be supported (I'm not sure what it means because I haven't looked)

Would you like to look at datapotato together some time?

@flyingmachine
Copy link
Contributor

BTW I think it's really cool that you're looking at these issues! I'm just hoping we don't end up with duplicated effort

@mitchkyle-reify
Copy link
Contributor Author

Thanks, I'm struggling with boot at the moment. it's giving me a strange error that I think is related to being on an M1 mac.

And that error on the CI seems like how I'm doing the dynamic loading might not work with clojurescript.

I'll read through datapotato, I was hoping for something backwards compatible with spec-gen because I need to add it to a code base that already uses that :P

@flyingmachine
Copy link
Contributor

flyingmachine commented Oct 19, 2022 via email

@flyingmachine
Copy link
Contributor

flyingmachine commented Oct 19, 2022 via email

@mitchkyle-reify
Copy link
Contributor Author

mitchkyle-reify commented Oct 20, 2022

I like datapotato, I like the next.jdbc integration, I like the improved data generations, a few issues though, I would have to go through the whole codebase and replace :spec-gen with :generate which is a pain but not then end of the world, the other is if I have an entity with fields called :generator or :schema, I don't seem to be able to overwrite them without the generation failing.

This PR can be like a drop-in enhancement for spec-gen, which is really what we need for the task at hand. I appreciate you taking the time to help me; If you'd rather put your focus towards datapotato rather than this repo, I would completely understand, and we could take it from here.

New pushed changes:

  • renamed it from franken-gen to specmonstah.generate for clarity
  • removed boot files
  • switch CI to use clojure deps
  • removed dynamic loading

@flyingmachine
Copy link
Contributor

@mitchkyle-reify I think it would be really useful to get on a zoom about this. How would you feel about that? I'm not sure I understand the issue you're running into when you mention having an entity with :generator or :schema fields.

Also, I get wanting to move forward with this so that you can meet your needs and move on. I'd like to chat about that more. If zoom doesn't work I'll try to put my thoughts together here. I'm nonrecursive on Clojurians slack, and [email protected] if you'd like to get in touch

@flyingmachine
Copy link
Contributor

OK I think I see what you mean about :generator and :schema. I've updated datapotato so that overwriting generated values per entity looks like this:

(dc/generate potato-db {:todo [[:_ {:generate {:set {:todo-title "..."}}}]]}

You can also specify other :generate config per-entity:

(deftest specify-generate-in-query
  (testing "can specify generate options in query terms"
    (let [gen (dc/generate
               {:schema   spec-schema
                :generate {:generator spec-generator}}
               {:todo-list [[1 {:generate {:schema    [:map
                                                       [:id ID]
                                                       [:created-by-id ID]
                                                       [:title [:enum "todo list title"]]]
                                           :generator malli-generator}}]]})]
      (is (= "todo list title"
             (get-in gen [:tl0 :title]))))))

I've also addressed the :spec-gen issue so that you shouldn't have to rewrite existing occurrences of :spec-gen.

@reifyrobot
Copy link

This PR is being flagged as STALE because it has not had recent activity in the last 60 days. It will be closed if no further activity occurs in the next 14 days. If you believe this repo should be excluded from this process, please add the repo to this list.

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

Successfully merging this pull request may close these issues.

3 participants