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

Fds 1843 use graph #1425

Closed
wants to merge 49 commits into from
Closed

Fds 1843 use graph #1425

wants to merge 49 commits into from

Conversation

afwillia
Copy link
Contributor

@afwillia afwillia commented May 7, 2024

Address FDS-1843. The purpose of this PR is to update all functions that accept a jsonld schema to also accept a pickle version of the graph. When a graph is supplied instead of a schema, the functions will skip the time-consuming step of reading the schema into a graph.

@linglp
Copy link
Contributor

linglp commented May 29, 2024

@afwillia Thanks for the PR. Please add PR description, including linking Jira issue with this PR and making sure that tests are passing. Also, I am not seeing any file changes related to tests, so please also change tests to make sure that we are testing data_model_graph_pickle as an additional parameter.

@andrewelamb
Copy link
Contributor

@afwillia It looks liky you are missing tests for generator.create_manifests: using both the graph object and pickle file

@afwillia afwillia requested a review from GiaJordan June 11, 2024 18:03
) -> None:
self.path_to_jsonld = path_to_jsonld

self.jsonld = load_json(self.path_to_jsonld)
if data_model_graph_pickle and not graph_data_model:
with open(data_model_graph_pickle, "rb") as file:
graph_data_model = pickle.load(file)
Copy link
Collaborator

@BryanFauble BryanFauble Aug 26, 2024

Choose a reason for hiding this comment

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

If I am reading this code correctly, does this accomplish anything?

This is being set on L53
self.graph_data_model = data_model_grapher.graph

On this L39 you are updating the attribute passed in if None:
graph_data_model = pickle.load(file)

But then graph_data_model is not actually being used anywhere to set anything on the AttributesExplorer class instance that was instantiated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thanks. I updated this to set self.graph_data_model on L37 and inside if not data_model_grapher on L47

pytest.param(("", "example.model.pickle"), marks=pytest.mark.xfail),
]
)
def attributes_explorer(request, helpers):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Take a look at this doc here: https://www.draconianoverlord.com/2017/11/28/using-given/when/then-for-tests.html/

Personally, I am a huge fan of giving each test a very explicit purpose. The way I do this is clearly state a set of criteria the test is expected to following in a:

# GIVEN some initial setup (Explain what the setup is doing)

# WHEN I apply some action after the initial setup (The functions you are testing)

# THEN I expect the output/behavior to look like (Add your assertions)

I added some tests like this in: #1472 if you wanted some examples

data_model_parser = DataModelParser(
path_to_data_model=self.path_to_json_ld,
)
if not data_model_graph_pickle:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Avoid doing this unless data_model_graph_pickle is a boolean.

if data_model_graph_pickle is not None

Copy link

sonarcloud bot commented Aug 27, 2024

@afwillia
Copy link
Contributor Author

I appreciate everyone's feedback and have incorporated most of it into this PR. @andrewelamb @linglp do you think this looks ready to merge? I have not addressed @BryanFauble 's comment about creating more readable tests, but I think the coverage is there.

@@ -1677,16 +1682,25 @@ def create_manifests(
"Please check your submission and try again."
)

data_model_parser = DataModelParser(path_to_data_model=path_to_data_model)
if not graph_data_model:
Copy link
Contributor

@andrewelamb andrewelamb Aug 27, 2024

Choose a reason for hiding this comment

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

You might want this to be if graph_data_model is None I'm not sure how nx.MultiDiGraph handles thruthyness.

@thomasyu888
Copy link
Member

Closing due to other PR

@thomasyu888 thomasyu888 deleted the FDS-1843-use-graph branch November 1, 2024 17:26
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.

6 participants