Getting Error "ERROR : app.Controller: View method 'get_csv_result " could not be found in current controller

Below is method I have defined in Controller class for “get_csv_result”:

def get_csv_result(self, params, **kwargs) ->DownloadResult:
        csv_string = self._get_processed_pdf(params)
        download_file = File.from_data(csv_string)
        return DownloadResult(download_file, 'result.csv')

And below is use of “get_csv_result” fun in Parametrization class:

step_3 = Step('Result', views=['get_csv_result'])

Below is snap of error I am getting while starting the app:

I am not sure where I am making mistake. Any help is appreciated.

Hi Abhishek,

Thanks for posting, I suspect your indent structure of your Controller is incorrect.
The correct structure would be something like:

class Controller(ViktorController):
    label = "Analysis"
    parametrization = Parametrization

    def get_csv_result(self, params, **kwargs) -> DownloadResult:
        csv_string = self._get_processed_pdf(params)
        download_file = File.from_data(csv_string)
        return DownloadResult(download_file, 'result.csv')

If possible you could share your full Controller so I can check it?

Hi, Thanks for reply. Indentation is correct in actual code, here its showing bit different but it is not the issue. Full controller code is bit lengthy, but I can share few part:

class Parametrization(ViktorParametrization):
    step_1 = Step('Upload file', views=['get_pdf_preview'], on_next=validate_step_1)
    step_2 = Step('Process file', views=['get_processed_pdf'])
    step_3 = Step('Result', views=['get_csv_result'])
class Controller(ViktorController):
    label = 'ABC'
    parametrization = Parametrization(width=40)
    viktor_enforce_field_constraints = True
    @PDFView('Uploaded PDF preview', duration_guess=1)
    def get_pdf_preview(self, params: Munch, **kwargs) -> PDFResult:
        #some_functionality, genearating csv_string
    def get_csv_result(self, params, **kwargs) ->DownloadResult:
        csv_string = self._get_processed_pdf(params)
        download_file = File.from_data(csv_string)
        return DownloadResult(download_file, 'result.csv')
   

Thanks for the elaboration,

I just realized, the view you are trying to include in the third step isn’t a view.
In the steps you can only include methods that are accompanied with an actual VIKTOR view decorator (e.g. DataView or GeometryView). You can see that the get_pdf_preview method is implemented just fine in the first step because it has a @PDFView decorator.

So I guess the question now is, what are you trying to accomplish with only having the DownloadResult available on the third step?

1 Like

Thanks for clarity, I am trying to visualize csv output result. How should I do that?

It depends on what data is in there, if its quite simple and small a DataView might suffice, otherwise you could use something like Plotly to create a table and visualize that in a PlotlyView or use something like Bokeh to create a table which you could pass in a WebView or as an image in an ImageView

Basically you’ll have to process the csv data somehow to a visual format. A good start is to look at Pandas to manipulate the data a little quicker.

hope that helps, and let me know if you have more questions!

1 Like

I have commented out step3(its above in comment) and added following step:

step_2.download_btn = DownloadButton("Ouput CSV", "get_csv_result", longpoll=True, flex=30,
                                         description='Result of Processed pdf')

When starting the app, I am getting following error:

Could you run viktor-cli check-system in order to get a little more detailed description of what connection seems to fail?

I am getting following output , I think It’s fine.

Did you try re-installing your app (viktor-cli install) and clearing your database (viktor-cli clear) before restarting the app (viktor-cli start)?

I am getting following error when using viktor-cli-clear command.

After a private call the matter has been resolved by having the environment admin revoke, and then reinstate the developer status. Then, after manually deleting the configuration file in the VIKTOR installation and going through the onboarding flow again, the account was activated :partying_face:

1 Like