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

more_robust_updk_import #2722

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion gdsfactory/read/from_updk.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@
script += "\n"

for block_name, block in conf.blocks.items():
parameters = block.parameters
if hasattr(block, "parameters"):
parameters = block.parameters
else:
print(f"{block_name=}, {block=} does not have parameters")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code_refinement): Consider replacing print statement with logging.

Using logging instead of print allows better control over the output and can be configured to include more information such as timestamps or log levels.

Suggested change
print(f"{block_name=}, {block=} does not have parameters")
import logging
logger = logging.getLogger(__name__)
if hasattr(block, "parameters"):
parameters = block.parameters
else:
logger.warning(f"{block_name=}, {block=} does not have parameters")
continue

continue

Check warning on line 112 in gdsfactory/read/from_updk.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/read/from_updk.py#L111-L112

Added lines #L111 - L112 were not covered by tests
Comment on lines +108 to +112
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Missing test for the new conditional logic handling blocks without parameters.

The addition of conditional checks for 'parameters' attribute in blocks requires corresponding unit tests to verify that blocks without parameters are handled correctly and that the function continues as expected.


parameters_string = (
", ".join(
[f"{p_name}:{p.type}={p.value}" for p_name, p in parameters.items()]
Expand Down
Loading