Coder Social home page Coder Social logo

Comments (10)

loldenburg avatar loldenburg commented on July 25, 2024 1

maybe improve this way:

filters = panel.get('segmentGroups') 
if filters is not None:
   for element in filters:

That being said, it is a bit dangerous to expect a certain model from a non-officially supported API. I would prefer just getting (or via an optional parameter) the raw JSON back and then be able to do what I need with it. I need to roll back to 0.2.4 now.

from adobe-analytics-api-2.0.

loldenburg avatar loldenburg commented on July 25, 2024 1

Boy sorry for the many messages, but I think you already had this option in mind with the projectClass parameter, however:

if projectClass:
 if verbose:
 print('building an instance of Project class')
 myProject = Project(res)
 return myProject
self.projectsDetails[projectId] = Project(res) !!! Response is forced into "Project" even when projectClass is False

from adobe-analytics-api-2.0.

loldenburg avatar loldenburg commented on July 25, 2024 1

Yeah it totally makes sense to cache the object in a certain standard data model, I was not disputing that, I just wondered why you forced this, relying on a certain model that may change soon as it is as you say unsupported and undocumented.
I hugely appreciate it anyway and I am aware of the potential problems that come with it. THANKS!

My scripts don't need to cache the project definition however and memory is always a potential issue, so being able to skip this row "self.projectsDetails[projectId] = Project(res)" entirely with a flag (e.g. cache=False) would be even a bit more performance and memory-saving.

from adobe-analytics-api-2.0.

loldenburg avatar loldenburg commented on July 25, 2024

I opened the project from the AA interface and saved it again. Now it worked. But there seems to be some issue with older projects.

I had the issue again with another project now, but I cannot see what the issue is. The workspace looks like a normal one. It was last modified in 2017 however. If there was some "open, save and close" workspace function in the API, we could work around such cases by simply re-saving the wspaces with modern definitions.

from adobe-analytics-api-2.0.

loldenburg avatar loldenburg commented on July 25, 2024

The problem is the new way that the response of the getProject request is forced into -> Union[dict,Project]
Here it tries to get a "segmentGroups" property which does not exist in all projects:

        for panel in workspace['panels']:
            if "reportSuite" in panel.keys():
                dict_elements['reportSuites'].append(panel['reportSuite']['id'])
            elif "rsid" in panel.keys():
                dict_elements['reportSuites'].append(panel['rsid'])
            filters: list = panel['segmentGroups']
            if len(filters) > 0:

The row where it breaks: filters: list = panel['segmentGroups']
This also explains why it did not cause issues before, only after updating the aa2 library yesterday.

from adobe-analytics-api-2.0.

loldenburg avatar loldenburg commented on July 25, 2024

I will send you an example response of such projects via email. As I said, I would want an option that prevents forcing the response into the Project dictionary.

from adobe-analytics-api-2.0.

pitchmuc avatar pitchmuc commented on July 25, 2024

Thanks a lot @loldenburg for the debug.

For the last message, I am trying to be smart (It doesn't suit me well apparently).
The idea is to cache the Project detail in an attribute (dictionary) so you can easily access them later on again if you need to.
So you don't need to do an API call again (as it is expensive in time and in API call budget - limit of 12 for 6s)

I replace it with a try:

try:
    self.projectsDetails[projectId] = Project(res)
except:
    if verbose:
      print('WARNING : Cannot convert Project to Project class')

For the original fail, I will fix it by returning an empty list:

filters: list = panel.get('segmentGroups',[])

As I am doing a if len(filters) > 0: later on.
EDIT : btw I am so happy I have set some type hint along the way so I now what I am supposed to expect.(the : list).
I encourage to do that when it is not up to you.

True, it is tough to expect anything from undocumented (unsupported?) API.
I still see lots of benefits from it though :)

from adobe-analytics-api-2.0.

pitchmuc avatar pitchmuc commented on July 25, 2024

I hope to make the changes tonight for an update in Git tomorrow.
Probably be a Patch (something like "0.2.6-1")

from adobe-analytics-api-2.0.

pitchmuc avatar pitchmuc commented on July 25, 2024

Sound argument. I'll add that option (and set it to False by default).
False = It is not cache by default.

from adobe-analytics-api-2.0.

pitchmuc avatar pitchmuc commented on July 25, 2024

Enhancement part of the 31fd34f commit.
fyi : I messed up the version number, the new version is 0.2.6 not the 0.2.6-1
You may have hard time installing it if you try a pip upgrade and you currently have the 0.2.6-1.
Nothing change except that part and some release info.
So you can stay with the 0.2.6-1

from adobe-analytics-api-2.0.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.