-
Notifications
You must be signed in to change notification settings - Fork 22
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: Add manufacture_data django command #369
Conversation
2eccbaa
to
28c7b29
Compare
28c7b29
to
f21002f
Compare
Hello @marlonkeating. I know this is just a draft. I'm going to check in with arch-bom about the planned how and where for developer data. See edx/edx-arch-experiments#138 |
24304f1
to
0c6b27f
Compare
0c6b27f
to
73698ff
Compare
e026502
to
3ff5f28
Compare
edx_django_utils/data_generation/management/commands/manufacture_data.py
Show resolved
Hide resolved
edx_django_utils/data_generation/management/commands/manufacture_data.py
Outdated
Show resolved
Hide resolved
edx_django_utils/data_generation/management/commands/manufacture_data.py
Outdated
Show resolved
Hide resolved
5b8f80c
to
6321589
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments/question mostly about documentation. Otherwise looks great and I'm excited to get this released!
|
||
Unsupported Cases | ||
----------------- | ||
One limitation of this script is that it can only fetch or customize, you cannot customize a specified, existing FK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot customize a specified, existing FK:
or customizations to any subclasses/FK's to the specified to an existing object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited for more clarity
defaults = dict( | ||
defaults._get_kwargs(), **arg_options | ||
) | ||
# Commented out section allows for unknown options to be passed to the command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should go to the top of the method, explaining why we have to redefine the core django function in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went ahead and removed the commented out code, and explained the disabled arg checking at the top. I figure if we ever want that code back, we know where we originally got it.
6321589
to
5531640
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits and requests for clarification. Also, I'm surprised that this passed the doc linter. That's not on you, but I think something is up with the way the linter is configured. It should complain when docstrings are not something like
def my_func(arg1):
Does an important thing.
More information about important thing.
Arguments:
arg1: Is a thing
README.rst
Outdated
@@ -23,13 +23,12 @@ This repository includes shared utilities for: | |||
|
|||
* `Logging Utilities`_: Includes log filters and an encrypted logging helper. | |||
|
|||
* `Monitoring Utilities`_: Includes Middleware and utilities for enhanced monitoring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, that wasn't my intention. It may have been a merge issue that I missed.
|
||
Unsupported Cases | ||
----------------- | ||
One limitation of this script is that it can only fetch or customize, you cannot customize a specified, existing FK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this sentence. Can you elaborate more on what we are fetching and customizing? And do you mean we cannot customize an existing object? There's not really a notion of customizing keys.
I also think modify
makes more sense than customize
but that's minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated based on @alex-sheehan-edx's comments
`./manage.py lms manufacture_data --model enterprise.models.EnterpriseCustomerUser --enterprise_customer <invalid uuid>` | ||
|
||
we'd get: | ||
`CommandError: Provided FK value: <SOMETHING BAD> does not exist on EnterpriseCustomer` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`CommandError: Provided FK value: <SOMETHING BAD> does not exist on EnterpriseCustomer` | |
`CommandError: Provided FK value: <invalid uuid> does not exist on EnterpriseCustomer` |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, made that correction based on @alex-sheehan-edx 's comment
edx_django_utils/data_generation/management/commands/manufacture_data.py
Outdated
Show resolved
Hide resolved
|
||
def is_not_pascal(string): | ||
""" | ||
helper method to detect if strings are not Pascal case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of Pascal case would be useful here (I'd never heard the term before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CapWords is how it's named in the python documentation, added note in the comments.
|
||
def __str__(self, level=0): | ||
""" | ||
Overridden str method to allow for proper tree printing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of the expected output would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best example is in the unit tests. I don't know that there's a more compact way to illustrate the output than by reading the code here, and referencing the unit test.
6deb17f
to
aeb961d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One incredibly obnoxious nit, otherwise looks great! Thanks for all your hard work on this.
|
||
def build_tree_from_field_list(list_of_fields, provided_factory, base_node, customization_value): | ||
""" | ||
Builds a non-binary tree of nodes based on a list of children nodes, using a base node and it's associated data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
Builds a non-binary tree of nodes based on a list of children nodes, using a base node and it's associated data | |
Builds a non-binary tree of nodes based on a list of children nodes, using a base node and its associated data |
aeb961d
to
e562a1d
Compare
test: Fix test configuration test: improve test coverage test: case for nonstandard model casing test: more coverage docs: Add documentation for manufacture_data docs: Setup documentation for manufacture_data style: Fix code quality errors style: Fix pycodestyle errors style: Fix isort errors test: remove unneeded test code test: error test coverage fix: support field names that don't match snake-cased model names test: remove unused code branches fix: Handle abstract classes during factory discovery fix: Clean up node tree logging docs: Update documentation docs: Update documentation based on comments chore: fix trailing whitespace chore: fix typo
e562a1d
to
0f1ad56
Compare
Description:
This change migrates the manufacture_data django command introduced in openedx/edx-enterprise#1826 to where it can be used outside of the enterprise ecosystem.
JIRA
ENT-7636
Installation/Testing instructions:
In Devstack, prior to being pushed to PyPi
Example:
docker cp ~/edx-repos/edx-django-utils/. {container uuid}:/lib/
Where
container uuid
can be found by runningdocker ps
Example:
python ./manage.py manufacture_data --model enterprise_catalog.apps.catalog.models.EnterpriseCatalog --title "Test Catalog"
Merge checklist:
Post merge:
finished. (https://github.com/openedx/edx-django-utils/releases/tag/v5.10.1)