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

RM-42 job config schema too complex #231

Merged
merged 9 commits into from
Apr 10, 2023

Conversation

Brunope
Copy link
Collaborator

@Brunope Brunope commented Mar 20, 2023

No description provided.

@Brunope Brunope changed the title Rm 42 job config schema too complex RM-42 job config schema too complex Mar 20, 2023
@Brunope
Copy link
Collaborator Author

Brunope commented Mar 20, 2023

Any advice on this @ryantimjohn? I'm not too happy with it so far. All the extra params needing to be passed around plus the type-checking info makes it more convoluted than I'd like. Also it's still "too complex". There's some logic around the arg_name that is hard to extract.

self.arg_parser.add_argument(false_arg_arg_name, **false_arg_kwargs)
self._configure_from_boolean(value, key, required_keys, formatted_key_name, kwargs)
if value.get('default') is True:
arg_name = "--no_" + formatted_key_name
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This branch isn't unit tested

@ryantimjohn
Copy link
Contributor

Any advice on this @ryantimjohn? I'm not too happy with it so far. All the extra params needing to be passed around plus the type-checking info makes it more convoluted than I'd like. Also it's still "too complex". There's some logic around the arg_name that is hard to extract.

I was thinking about this with my own over complex function and read somewhere online "if you're passing around too many parameters you might have an object sitting in there." I think I'm going to work a parameters object into mine, don't know if that's helpful here.

@ryantimjohn
Copy link
Contributor

As for extracting the arg_name logic, don't see it right away but happy to jump on to paired sometime, will Slack you!

@Brunope Brunope force-pushed the RM-42-job-config-schema-too-complex branch from 58f796c to e46b9a5 Compare March 28, 2023 18:29
@Brunope
Copy link
Collaborator Author

Brunope commented Mar 29, 2023

Odd, getting a bunch of these errors, I don't think it's related to my changes but it's possible

FAILED test_records_unload_datetime.py::RecordsUnloadDatetimeIntegrationTest::test_unload_datetime - sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InsufficientPrivilege) permission denied for relation svv_table_info

[SQL: 
                        SELECT table_id
                        FROM
                            SVV_TABLE_INFO
                        WHERE 1
                            AND schema = 'public'
                            AND "table" = '*****_24498_1680105943';
                        ]
(Background on this error at: https://sqlalche.me/e/14/f405)

@ryantimjohn
Copy link
Contributor

Odd, getting a bunch of these errors, I don't think it's related to my changes but it's possible

FAILED test_records_unload_datetime.py::RecordsUnloadDatetimeIntegrationTest::test_unload_datetime - sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InsufficientPrivilege) permission denied for relation svv_table_info

[SQL: 
                        SELECT table_id
                        FROM
                            SVV_TABLE_INFO
                        WHERE 1
                            AND schema = 'public'
                            AND "table" = '*****_24498_1680105943';
                        ]
(Background on this error at: https://sqlalche.me/e/14/f405)

Very bizarre, wonder if one of the tokens died in the background or something but... that seems extremely unlikely.

@@ -60,6 +60,7 @@ def configure_from_properties(self,
properties: JsonSchema,
required_keys: Iterable[str],
prefix: str = '') -> None:
self.required_keys = required_keys
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Really not a huge fan of setting self vars outside of __init__, but it does make the rest of the code easier. To move it to __init__ would require making new overloaded init functions that accept more params, which I'm not sure I want to do

Copy link
Contributor

Choose a reason for hiding this comment

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

that makes sense. Does adding a setter method to the class make sense? Then, at least, when assessing the class's code, you'd know what potential attributes the class had?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you explain a bit more? I'm not really sure what you mean

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, please ignore last comment, wrote very quickly.

Basically, I wonder if it just makes sense to break out the piece where you assign the required_keys attribute into a separate set_required_keys method and then just call that method in the configure_from_properties method. Not sure it's worth the trouble.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, sure, is the goal simply to make it more explicit?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep!

@Brunope Brunope marked this pull request as ready for review April 1, 2023 00:12
Copy link
Contributor

@ryantimjohn ryantimjohn left a comment

Choose a reason for hiding this comment

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

Changes look good! A lot easier to read now.

@Brunope Brunope added this pull request to the merge queue Apr 10, 2023
Merged via the queue into main with commit 2fa6e6c Apr 10, 2023
@Brunope Brunope deleted the RM-42-job-config-schema-too-complex branch April 11, 2023 00:16
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.

2 participants