Skip to content

Can't update problem status with [WARN] Failed to get memory percentile. #195

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

Closed
tomleung1996 opened this issue Mar 9, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@tomleung1996
Copy link

🐛 Bug Report

When I submitted the answer and get accepted, the last line of the response was [WARN] Failed to get memory percentile.

And with this warning, the problem status cannot be updated, even though my answer was accepted.

problem

response

To Reproduce

Just submit the question.

Expected behavior

Problem status not updated

Your Environment

  • os: Windows 10, 1809
  • extension settings:
  • nodejs version: v10.15.2
  • vscode version: 1.32.1
  • extension version: 0.12.0
@aaronbai
Copy link

I have the same issue on Mac using Golang.

@Vigilans
Copy link
Contributor

In fact, the submit command and result provider do not contain logic to update/refresh the tree explorer...

Seems that with or without the [WARN] Failed to get memory percentile message, the problem status will not be updated?

Do you mean after refreshing, the problem status still is not updated?

@tomleung1996
Copy link
Author

In fact, the submit command and result provider do not contain logic to update/refresh the tree explorer...

Seems that with or without the [WARN] Failed to get memory percentile message, the problem status will not be updated?

Do you mean after refreshing, the problem status still is not updated?

Yes, after refreshing

@Vigilans
Copy link
Contributor

@tomleung1996 Could you please provide the accepted code for the convenience of reproducing the bug?

@tomleung1996
Copy link
Author

@tomleung1996 Could you please provide the accepted code for the convenience of reproducing the bug?

It seems that this situation has some uncertainty. Some questions' status can be updated today, but others still not.
Solution for No.112 Pathsum

class Solution(object):
    def hasPathSum(self, root, sum):
        """
        :type root: TreeNode
        :type sum: int
        :rtype: bool
        """
        if not root:
            return False
        sum -= root.val
        if sum == 0 and not root.left and not root.right:
            return True
        return self.hasPathSum(root.left, sum) or self.hasPathSum(root.right, sum)

@jdneo jdneo added the bug Something isn't working label Mar 12, 2019
@Vigilans
Copy link
Contributor

Vigilans commented Mar 12, 2019

@tomleung1996 Yes, I failed to trigger the warning.

After some efforts of investigation, I finally get to know that it is not the problem with skygragon's leetcode-cli, but @jdneo 's forked version.

There's

        if (result.memory && result.memory_percentile)
          printLine(result, 'Your memory usage beats %d %% of %s submissions (%s)',
              result.memory_percentile.toFixed(2), result.lang, result.memory);
        else
          return log.warn('Failed to get memory percentile.');

And at the last line of function there is:

      // update this problem status in local cache
      core.updateProblem(problem, {state: (result.ok ? 'ac' : 'notac')});

Originally, the former code logic was wrapped in a callback, so when log.warn makes the callback returns, the latter code can still be executed.

Yet now the former code is exposed in the same level as the latter, so when the return is met, the latter code is skipped, resulting in the local cache not updated.

If you delete the cache in $HOME/.lc, the behavior may return right.

@jdneo
Copy link
Member

jdneo commented Mar 12, 2019

@tomleung1996 Will your problem be solved if adopting the workaround that @Vigilans provides?

@tomleung1996
Copy link
Author

@tomleung1996 Will your problem be solved if adopting the workaround that @Vigilans provides?

Works fine for me, thanks! XD

@jdneo
Copy link
Member

jdneo commented Mar 13, 2019

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants