Skip to content

Portable Installation #114

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

Open
RoyiAvital opened this issue Feb 4, 2017 · 9 comments
Open

Portable Installation #114

RoyiAvital opened this issue Feb 4, 2017 · 9 comments

Comments

@RoyiAvital
Copy link

Hello,

Currently the ploy.ly MATLAB Setup does some nasty things:

  1. Copy Plot.Ly into MATAB Toolbox folder.
  2. Put files into User Folder.

I propose much simpler way and a portable way - Use only the folder plotly was copied into.
Only add that folder to MATLAB Path (If user wants that).

All can be done easily by changing few lines.

Thank You.

@twocs
Copy link

twocs commented Apr 8, 2017

It seems like you are looking at two problems. The first is adding Plotly as a Toolbox; the second is that files are added to the user folder.

For the first: Actually it is possible to use Plotly that way. If you are an advanced user, you don't need to run plotlysetup.

  1. Download plotly/MATLAB-Online from github into folder of your choice.
  2. Add that folder and its subfolders to your path, e.g. with addpath(genpath(<path_to_plotly_MATLAB-Online>))
  3. Run saveplotlycredentials('DemoAccount', 'lr1c37zw81') with your credentials

However, note that plotly credentials must still be located in the proper folder (step 3). Quite a few changes would be needed to fix that part.

@RoyiAvital
Copy link
Author

Why not build in a portable manner? All kept inside one folder?

@twocs
Copy link

twocs commented Apr 8, 2017

I agree with you, @RoyiAvital, that portable would be nice, especially for offline use, or for multiple configs or credentials. I was just clarifying that there are two issues that you mentioned and in my opinion, the first issue is possible to work around. The steps I suggested are the same as used for using plotly/MATLAB-Online within a Jupyter notebook here: https://github.com/imatlab/imatlab

I just filed issue reports to both plotly/MATLAB-Online and to plotly/plotly.py related to the config and credential files, so that's why I also responded to your similar issue report.
plotly/MATLAB-Online#120
plotly/plotly.py#728

I would make a pull request myself to improve the user files, but it seems like they affect multiple parts of the code, and they are somewhat parallel to the structure used for other plotly languages.

@RoyiAvital
Copy link
Author

Any update on that?

It will be really helpful allowing portable installation.

Thank You.

@twocs
Copy link

twocs commented Jun 13, 2017

Sorry, I'm really not sure what you're looking for. Do you want to use plotly? Either run the plotlysetup or copy the whole folder as I described. What part of the instructions I gave don't meet your expectations?

@RoyiAvital
Copy link
Author

Hi,

On the one hand you agree with me on the other you ask what I want?

What I want is to have Plotly save all its configuration files within its folder and not in the User Profile Folder.
It can be done manually, I wanted it to be official and automatically (At least a choice to do so).

Thank You.

@twocs
Copy link

twocs commented Jun 13, 2017

Hi, I only ask because your initial question asked how to load Plotly without it adding as a toolbox, which it can do (but is undocumented). As far as I can see, certain parts of Plotly-MATLAB have hard-coded the config directory. The devs have not responded to my config file requests (above), and looking at other issues, I don't think they will get to it any time soon.

As I see it, Plotly does not have any developers actively working on fixing issues for project (40+ open issues). However, they do accept pull requests (0 open pull requests, most pull requests were accepted). Therefore, if we want the user profile folder to be "official and automatic", we need to code the changes and submit the pull request. Or wait for a major refactor.

@RoyiAvital
Copy link
Author

My work around to generate a Portable installation is:

  1. From plotlysetup() add a remark to the section which tries to install PlotLy as a toolbox. Lines 47 - 138.
  2. Edit the function getuserdir (In the plotly\plotly_aux folder) to return the path to the folder PlotLy is installed to.
  3. Run setup as instructed.

This will all needed credentials and offline files in the same folder as the user installed.
This allows, for instance, using PlotLy on the same computer with 2 different accounts, etc...

@RoyiAvital
Copy link
Author

RoyiAvital commented Feb 26, 2025

My workaround for version 3.0:

  1. Download the master and extract the content of its plotly folder into PlotLy folder on desired path.
  2. Run addpath(genpath('PlotLy'));.
  3. Edit plotlyoffline.m (In PlotLy\plotly_offline_aux):
function response = plotlyoffline(plotlyfig)
    % Generate offline Plotly figure saved as an html file within 
    % the current working directory. The file will be saved as: 
    % 'plotlyfig.PlotOptions.FileName'.html. 
    
    % create dependency string unless not required
    if plotlyfig.PlotOptions.IncludePlotlyjs
        % grab the bundled dependencies
        userHome = getuserdir();
        plotlyConfigFolder = fullfile(userHome,'.plotly');
        plotlyJSFolder = fullfile(plotlyConfigFolder, 'plotlyjs');
        %--------------------------------Royi--------------------------------%
        filePath = mfilename('fullpath');
        [folderPath, fileName] = fileparts(filePath);
        plotlyJSFolder = folderPath;
        %--------------------------------Royi--------------------------------%
        bundleName = 'plotly-matlab-offline-bundle.js';
        bundleFile = fullfile(plotlyJSFolder, bundleName);
  1. Save the JS file plotly\plotly_offline_aux. Run the following while inside the PlotLy\plotly_offline_aux folder:
plotly_bundle = webread('http://cdn.plot.ly/plotly-latest.min.js');
bundle = escapechars(plotly_bundle);
file_id = fopen('plotly-matlab-offline-bundle.js', 'w'); 
fprintf(file_id, '%s', bundle);
fclose(file_id); 
  1. Test with
hF = figure();
plot(1:10);
fig2plotly(hF);
  1. Clear the HTML files in PlotLy\plotly_offline_aux from time to time.

It would be great to have support for "Portable" installation where the JS file is kept within the folder yet the HTML files are generated inside Windows' TEMP folder where they should be saved.

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

No branches or pull requests

2 participants