microsoft / BackwardCompatibilityML

Project for open sourcing research efforts on Backward Compatibility in Machine Learning
https://backwardcompatibilityml.readthedocs.io/en/latest/
MIT License
71 stars 14 forks source link

[QUESTION] Expected behavior of CompatibilityAnalysis tool from pip install #145

Open seanytak opened 3 years ago

seanytak commented 3 years ago

Hey folks!

I noticed that on the README there's no installation instructions for installing this package from PyPI even though it's published there. I've gone ahead and tried that workflow out but it seems that the *.ts and *.tsx files don't get downloaded so the CompatbilityAnalysis tool isn't usable with this workflow at the moment. Is the current intended workflow to fork / clone the project and start from there?

Thanks!

ilmarinen commented 3 years ago

Hey Sean,

The *.ts and *.tsx are not intended to be downloaded. The CompatibilityAnalysis tool does work with the pip install from PyPi scenario.

Though if you ran into a specific issue running it. Do let us know on here and we will do our best to address it ASAP.

Thank you for trying out our tool!

seanytak commented 3 years ago

Thanks for the quick response!

So if I try to use the CompatibilityAnalysis tool (referencing this example from the notebook examples) I end up with the following error

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-35-6d765447bec1> in <module>
----> 1 analysis = CompatibilityAnalysis("sweeps-lfw", n_epochs, h1, h2, train_loader, test_loader,
      2     batch_size, batch_size,
      3     OptimizerClass=optim.SGD,
      4     optimizer_kwargs={"lr": learning_rate, "momentum": momentum},
      5     NewErrorLossClass=bcloss.BCCrossEntropyLoss,

~/projects/Responsible%20AI/venv/lib/python3.8/site-packages/backwardcompatibilityml/widgets/compatibility_analysis/compatibility_analysis.py in __init__(self, folder_name, number_of_epochs, h1, h2, training_set, test_set, batch_size_train, batch_size_test, lambda_c_stepsize, OptimizerClass, optimizer_kwargs, NewErrorLossClass, StrictImitationLossClass, performance_metric, port, new_error_loss_kwargs, strict_imitation_loss_kwargs, get_instance_image_by_id, get_instance_metadata, device, use_ml_flow, ml_flow_run_name)
    277         api_service_environment = build_environment_params(self.flask_service.env)
    278         api_service_environment["port"] = self.flask_service.port
--> 279         html_string = render_widget_html(api_service_environment)
    280         self.html_widget = HTML(html_string)
    281         display(self.html_widget)

~/projects/Responsible%20AI/venv/lib/python3.8/site-packages/backwardcompatibilityml/widgets/compatibility_analysis/compatibility_analysis.py in render_widget_html(api_service_environment)
     76     css_path = '/'.join(('resources', 'widget.css'))
     77     html_template_path = '/'.join(('resources', 'widget.html'))
---> 78     widget_javascript = pkg_resources.resource_string(
     79         resource_package, javascript_path).decode("utf-8")
     80     widget_css = pkg_resources.resource_string(

~/projects/Responsible%20AI/venv/lib/python3.8/site-packages/pkg_resources/__init__.py in resource_string(self, package_or_requirement, resource_name)
   1153     def resource_string(self, package_or_requirement, resource_name):
   1154         """Return specified resource as a string"""
-> 1155         return get_provider(package_or_requirement).get_resource_string(
   1156             self, resource_name
   1157         )

~/projects/Responsible%20AI/venv/lib/python3.8/site-packages/pkg_resources/__init__.py in get_resource_string(self, manager, resource_name)
   1399 
   1400     def get_resource_string(self, manager, resource_name):
-> 1401         return self._get(self._fn(self.module_path, resource_name))
   1402 
   1403     def has_resource(self, resource_name):

~/projects/Responsible%20AI/venv/lib/python3.8/site-packages/pkg_resources/__init__.py in _get(self, path)
   1624 
   1625     def _get(self, path):
-> 1626         with open(path, 'rb') as stream:
   1627             return stream.read()
   1628 

FileNotFoundError: [Errno 2] No such file or directory: '/home/setakafu/projects/Responsible%20AI/venv/lib/python3.8/site-packages/backwardcompatibilityml/widgets/compatibility_analysis/resources/widget-build.js'
ilmarinen commented 3 years ago

Hey Sean,

Ouch that looks like the package wasn't built and published correctly. Apologies for that!

I'll take a look at that and anticipate having a fix in by next week. I'll reply to this thread once it is done to notify you.

Thank you for catching this bug.

ilmarinen commented 3 years ago

Sean,

I was not able to duplicate your error. Here's what I did:

  1. Created a fresh virtual environment.
  2. Activated it and did: pip install backwardcompatibilityml.
  3. I also had to install torchvision==0.6.1, matplotlib and jupyter.
  4. Then I ran the notebook with no issues.

From your error logs, it seems that you are using Python 3.8. We have not yet tested out the package on Python 3.8.

Would you be able to test it out on Python 3.6 ? I wonder if this might be an issue specific to Python 3.8.

jlema commented 3 years ago

@seanytak - is Python 3.8 a hard requirement for your project? If not, could you please test out with Python 3.6?