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

Allow users to create all types of Artifact from Local Data #1153

Merged
merged 54 commits into from
Apr 11, 2023

Conversation

Fanjia-Yan
Copy link
Contributor

@Fanjia-Yan Fanjia-Yan commented Mar 30, 2023

[## Describe your changes and why you are making these changes

  1. Enable Local Data type as Parameter Artifact JSON ,PICKLE, STRING, BYTES, TF_KERAS with client.create_param("name, default = "path/to/file", use_local=True, as_type= ArtifactType.xx). We extract the content of the file based on the type and serve it as content for parameter artifact.

Testing:
The test test_all_local_data_types is similar to test_all_param_types except that all the data is coming from local data.

Related issue number (if any)

ENG-2585

Loom demo (if any)

Checklist before requesting a review

  • I have created a descriptive PR title. The PR title should complete the sentence "This PR...".
  • I have performed a self-review of my code.
  • I have included a small demo of the changes. For the UI, this would be a screenshot or a Loom video.
  • If this is a new feature, I have added unit tests and integration tests.
  • I have run the integration tests locally and they are passing.
  • I have run the linter script locally (See python3 scripts/run_linters.py -h for usage).
  • All features on the UI continue to work correctly.
  • Added one of the following CI labels:
    • run_integration_test: Runs integration tests
    • skip_integration_test: Skips integration tests (Should be used when changes are ONLY documentation/UI)

](https://linear.app/aqueducthq/issue/ENG-2585/allow-users-to-create-all-types-of-parameters-from-local-data)

@Fanjia-Yan Fanjia-Yan added the run_integration_test Triggers integration tests label Mar 30, 2023
Fanjia Yan added 4 commits March 31, 2023 09:36
…ub.com:aqueducthq/aqueduct into eng-2585-allow-users-to-create-all-types-of
@Fanjia-Yan Fanjia-Yan changed the base branch from eng-2584-allow-users-to-create-table-and-image to main April 1, 2023 00:37
@Fanjia-Yan Fanjia-Yan changed the base branch from main to eng-2584-allow-users-to-create-table-and-image April 3, 2023 18:24
@Fanjia-Yan Fanjia-Yan changed the base branch from eng-2584-allow-users-to-create-table-and-image to main April 3, 2023 18:24
@Fanjia-Yan Fanjia-Yan marked this pull request as ready for review April 3, 2023 22:21
return input

with open("data/test.pickle", "wb") as file:
pickle.dump(ArtifactType, file)
Copy link
Contributor Author

@Fanjia-Yan Fanjia-Yan Apr 3, 2023

Choose a reason for hiding this comment

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

To test pickle local data. I save class ArtifactType into a pickable file, load it as local data parameter and check for equality.

In test_all_param_types, we dynamically created an EmptyClass, put it in aq.create_param(), and check for equality.

I didn't do what test_all_param_types did is because pickle.load complain a lot in pytest. Would that be enough of coverage?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you share the error you were seeing after doing what test_all_param_types does.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we try to test this the same way of creating an empty class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2023-04-07 at 3 09 09 PM

I have been researching on this error and a lot of the complaints are coming from using multiprocessing package. I suspect that pytest is also using some sort of multiprocessing which causes the pickle.dump to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created https://linear.app/aqueducthq/issue/ENG-2774/investigate-the-limitation-of-artifacttypepicklable-from-create-param. Feel free to give it a read to see if the issue makes sense

@Fanjia-Yan Fanjia-Yan requested a review from saurav-c April 3, 2023 22:34
Copy link
Contributor

@saurav-c saurav-c left a comment

Choose a reason for hiding this comment

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

Looks good for the most, but left a few comments that we should get resolved before merging

Unable to check that the input is picklable, since `pickle.loads()`
complains about `import of module 'param_test' failed`.
"""
print(input)
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets remove this print statement

return input

with open("data/test.pickle", "wb") as file:
pickle.dump(ArtifactType, file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you share the error you were seeing after doing what test_all_param_types does.

return input

with open("data/test.pickle", "wb") as file:
pickle.dump(ArtifactType, file)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we try to test this the same way of creating an empty class

PICKLE = "pickle"
STRING = "string"
BYTES = "bytes"
TF_KERAS = "tensorflow-keras-model"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a test case for TF_KERAS

return Image.open(path)


def _read_local_json_content(path: str) -> Any:
with open(path, mode="rb", encoding=DEFAULT_ENCODING) as file:
return json.load(file.read())
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to do json.load(file) directly

@Fanjia-Yan Fanjia-Yan merged commit dee7d72 into main Apr 11, 2023
@vsreekanti vsreekanti deleted the eng-2585-allow-users-to-create-all-types-of branch April 11, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run_integration_test Triggers integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants