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

[NEAT-745] 🫵 feat; Support setting reference model directly #982

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

doctrino
Copy link
Collaborator

@doctrino doctrino commented Feb 7, 2025

image

Copy link

github-actions bot commented Feb 7, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
14654 11734 80% 60% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite/neat/_session/_to.py 80% 🟢
TOTAL 80% 🟢

updated for commit: b508a28 by action🐍

Comment on lines +94 to +117
if include_reference is not False:
if include_reference is True and self._state.last_reference is not None:
ref_rules: InformationRules | DMSRules | None = self._state.last_reference
elif include_reference is True:
ref_rules = None
else:
if not self._state.client:
raise NeatSessionError("No client provided!")
ref_rules = None
with catch_issues() as issues:
ref_read = DMSImporter.from_data_model_id(self._state.client, include_reference).to_rules()
if ref_read.rules is not None:
ref_rules = ref_read.rules.as_verified_rules()
if ref_rules is None or issues.has_errors:
issues.action = f"Read {include_reference}"
return issues
if ref_rules is not None:
prefix = "Ref"
reference_rules_with_prefix = self._state.last_reference, prefix
if (
isinstance(ref_rules.metadata, DMSMetadata)
and ref_rules.metadata.as_data_model_id() in COGNITE_MODELS
):
prefix = "CDM"
reference_rules_with_prefix = ref_rules, prefix
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 is something very special for writing to Excel, so kept the logic here.

@@ -35,17 +39,18 @@ def __init__(self, state: SessionState, verbose: bool) -> None:
def excel(
self,
io: Any,
include_reference: bool = True,
include_reference: bool | DataModelIdentifier = True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is small feature which does not have to be behind an alpha flag.

@doctrino doctrino marked this pull request as ready for review February 7, 2025 15:07
@doctrino doctrino requested a review from a team as a code owner February 7, 2025 15:07
Base automatically changed from wrapping-issues to main February 7, 2025 19:56
@doctrino doctrino merged commit d8bbc07 into main Feb 7, 2025
6 checks passed
@doctrino doctrino deleted the reference-directly branch February 7, 2025 20:58
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