Skip to content
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

Port to Python 3 #10

Merged
merged 17 commits into from
May 15, 2020
Merged

Port to Python 3 #10

merged 17 commits into from
May 15, 2020

Conversation

JuiP
Copy link
Member

@JuiP JuiP commented Apr 19, 2020

Tested; Apart from the two issues I didnot notice differences in python3 branch and master.
Differences between this branch and master-

  • After selecting the correct object, master displays a smile emoji but after port to python3 seen as a question mark. Still haven't found the cause
  • A Pango-Warning is seen after ff4f92c
    Invalid UTF-8 string passed to pango_layout_set_text()

Observed this before port to python3
In master:

  • Collaboration does not include turns so joiner can only join the activity but treated as two separate games. Collaboration makes no sense if there are no turns.

After porting ; In python3 branch:

  • yet to test if collaboration is same as in master

@quozl @chimosky Please review changes!

@JuiP
Copy link
Member Author

JuiP commented Apr 19, 2020

Tested Collaboration on the branch python3, logs are clean for the sharer and is same as master, but got this traceback for the joiner:

Traceback (most recent call last):
  File "/usr/share/sugar/activities/recall.activity/game.py", line 166, in _dance_step
    self._new_game()
  File "/usr/share/sugar/activities/recall.activity/game.py", line 264, in _new_game
    self._parent.send_new_game()
  File "/usr/share/sugar/activities/recall.activity/RecallActivity.py", line 197, in send_new_game
    payload = json_dump(self._game.save_game())
  File "/usr/share/sugar/activities/recall.activity/utils.py", line 52, in json_dump
    jdump(data, _io)
  File "/usr/lib/python2.7/json/__init__.py", line 190, in dump
    fp.write(chunk)
TypeError: unicode argument expected, got 'str' 

What perplexed me was the line: File "/usr/lib/python2.7/json/__init__.py", line 190, in dump when I had ported the activity to python 3 why is it still using python2.7 ? I checked, both the VMs I used to test, git branch is set to python3

@quozl
Copy link
Contributor

quozl commented Apr 20, 2020

Do remember to restart Sugar. At the moment Sugar does not detect change to exec in activity.info. The info files are loaded when Sugar starts or a new directory appears. Alternatively, rename the directory to some place other than /usr/share/sugar/activities, wait a second, then rename it back. Restarting Sugar is in the Python 3 Porting Guide.

@chimosky
Copy link
Member

When you say " Collaboration does not include turns so joiner can only join the activity but treated as two separate games. Collaboration makes no sense if there are no turns." do you mean the game state isn't shared?

@JuiP
Copy link
Member Author

JuiP commented May 8, 2020

When you say " Collaboration does not include turns so joiner can only join the activity but treated as two separate games. Collaboration makes no sense if there are no turns." do you mean the game state isn't shared?

@chimosky Yes, also I had seen the code, it does not include "having turns" , like paths/ memorize/ sugarchess defines a variable and stores boolean value to decide who plays when the game board is shared

@quozl
Copy link
Contributor

quozl commented May 8, 2020

Some activities were written by copying the source code of another activity and hacking on it until it worked well enough. That can cause activities that seem to have a collaboration feature but don't. Do you think this might be that scenario?

@JuiP
Copy link
Member Author

JuiP commented May 8, 2020

Some activities were written by copying the source code of another activity and hacking on it until it worked well enough. That can cause activities that seem to have a collaboration feature but don't. Do you think this might be that scenario?

Well yes, because all one can do is join the activity.

@quozl
Copy link
Contributor

quozl commented May 8, 2020

Thanks. I'm not familiar with the activity user experience or data model. Best I've found is app store narrative. I've not worked on the activity before.

In the repository commit history, a133c0a was a widespread change to how collaboration worked. Is it possible that this change broke collaboration?

After resolving the above, do you think it makes sense for the activity to support collaboration?

@JuiP
Copy link
Member Author

JuiP commented May 8, 2020

I'm not familiar with the activity user experience or data model. Best I've found is app store narrative. I've not worked on the activity before.

It mentions: "The fourth game prompts the user to identify the image which had not appeared in the grid. This time, the images differ by shape and color. Again, it starts easy, with just three images to remember, but gets very challenging as the number of images increases."
This fourth-game is not implemented, you can see the differences in the icons on toolbar in the screenshots I added in 81dacb3 and the one on the app store

In the repository commit history, a133c0a was a widespread change to how collaboration worked. Is it possible that this change broke collaboration?

This may or may not be the case, I need to test the repository at that point to know for sure. On a quick look, I don't see a variable that acts like a turns variable in the code that was changed.

After resolving the above, do you think it makes sense for the activity to support collaboration?

Honestly, if there is no score board, the collaboration doesn't make sense in this activity (there is no incentive for a child to play more attentively and give the correct answer). It is like playing an individual game but just waiting for the other person to take their turn. The activity is just like a set of questions to be answered and it makes no difference to the child whether he has to answer all the questions or have alternate questions answered by the other player.

@quozl
Copy link
Contributor

quozl commented May 8, 2020

Thanks. Tested abf1183.

  • the toolbar grows at the same time "Recall which image was repeated" is shown,
  • there's a Pango-WARNING in logs, invalid UTF-8 string,

I agree it doesn't make sense to have collaboration.

In looking at history and source code I found "dotlist" was in the metadata, and I remember seeing that in another activity. A search shows where else it can be found.

So I constructed a timeline of the activities that mention it;

Also related to sugarlabs/cookie-search-activity#18.

Copy link
Member

@Saumya-Mishra9129 Saumya-Mishra9129 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuiP you can cherry-pick 051dd9c. I have solved

A Pango-Warning is seen after ff4f92c
Invalid UTF-8 string passed to pango_layout_set_text()

And also after solving I didnt get again-

After selecting the correct object, master displays a smile emoji but after port to python3 seen as a question mark. Still haven't found the cause

For reference I looked at GNOME DEVELOPERS page and found out that second argument taken by set_text (length) is maximum length of text , in bytes. And -1 indicates that the string is nul-terminated and the length should be calculated. So I tried using -1 there as it is also used in ruler and it worked.Thanks.

sprites.py Outdated Show resolved Hide resolved
@chimosky
Copy link
Member

chimosky commented May 8, 2020

Honestly, if there is no score board, the collaboration doesn't make sense in this activity (there is no incentive for a child to play more attentively and give the correct answer). It is like playing an individual game but just waiting for the other person to take their turn. The activity is just like a set of questions to be answered and it makes no difference to the child whether he has to answer all the questions or have alternate questions answered by the other player.

I agree.

  • the toolbar grows at the same time "Recall which image was repeated" is shown,

Yes noticed this too, removing the line wrap set on the label fixes it.

  • there's a Pango-WARNING in logs, invalid UTF-8 string,

@JuiP You should update sprites.py and make necessary fixes.

@JuiP JuiP force-pushed the python3 branch 2 times, most recently from 6eb5e60 to 3e21299 Compare May 10, 2020 18:24
@JuiP
Copy link
Member Author

JuiP commented May 10, 2020

Thanks @Saumya-Mishra9129 done in 3e21299

@JuiP
Copy link
Member Author

JuiP commented May 10, 2020

Honestly, if there is no score board, the collaboration doesn't make sense in this activity (there is no incentive for a child to play more attentively and give the correct answer). It is like playing an individual game but just waiting for the other person to take their turn. The activity is just like a set of questions to be answered and it makes no difference to the child whether he has to answer all the questions or have alternate questions answered by the other player.

I agree it doesn't make sense to have collaboration. (quozl)

I agree. (chimosky)

About collaboration, I think it is better to keep the status of collaboration as it is at the moment. Later, maybe we could add scoreboard feature so that it is more meaningful.
@walterbender @quozl @chimosky what do you suggest? Did you have anything specific in mind when you created this activity?

@walterbender
Copy link
Member

I wonder if it might be fun to have the players have to cooperate to decide on an answer... The game is quite challenging as it progresses.

@quozl
Copy link
Contributor

quozl commented May 14, 2020

The next release will be the first release to let the activity run on Sugar again after the Python 3 transition, so for the moment I think it is fine for collaboration to be functionally unchanged; it doesn't work in the latest release, so it is fine if it doesn't work in the next release. I don't think the collaboration code should be ported. So I suggest ripping it out. If it makes sense to add collaboration, that can be in another release. I don't think it will save any time to keep broken collaboration code in the source.

See branch inhume-sharing for commits against master that remove collaboration. I was able to rebase your latest commit as 5533c49 after resolving a few conflicts. If you wish to proceed on this basis, you might try rebasing as I did, or at least compare 5533c49 against master.

Saumya-Mishra9129 and others added 3 commits May 14, 2020 11:43
Invalid UTF-8 string is passed to pango_layout_set_text() is fixed
@JuiP
Copy link
Member Author

JuiP commented May 14, 2020

Tested. Ready to be merged :) @quozl @chimosky

Copy link
Member

@srevinsaju srevinsaju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great; No errors


@JuiP Is collaboration fixed or is it planned for a lter release as @quozl suggested?

@JuiP
Copy link
Member Author

JuiP commented May 14, 2020

Thanks for testing @srevinsaju! :)

@JuiP Is collaboration fixed or is it planned for a lter release as @quozl suggested?

Planned for a later release for now

@srevinsaju
Copy link
Member

srevinsaju commented May 14, 2020

@JuiP Thanks for the quick reply.

In that case; I would be more glad if you change this to

self.max_participants = 1

This would disable the collaboration button too; This removes the confusion if collaboration is implemented or not; from the users' side

@JuiP
Copy link
Member Author

JuiP commented May 14, 2020

@srevinsaju It has been done in 666da4c. You can see if you try using that button, then it gets disabled. If you are referring to your PR in iknowSriLanka then the button implementation was a little different than in this activity.

@srevinsaju
Copy link
Member

srevinsaju commented May 14, 2020

No, I am not talking about my implementation; setting self.max_participants had been quite a standard way to disable the collaboration button; apparently, its not getting disabled due to some reason as it should. I will check into the code

@srevinsaju
Copy link
Member

srevinsaju commented May 14, 2020

@JuiP, although setting

self.max_participants = 1

at the __init__, you might have forgotten to remove

self.max_participants = 4

on L78

https://github.com/JuiP/recall/blob/python3/RecallActivity.py#L75-L80

    def _setup_toolbars(self, have_toolbox):
        """ Setup the toolbars. """

        self.max_participants = 4
        toolbox = ToolbarBox()

@JuiP
Copy link
Member Author

JuiP commented May 14, 2020

@srevinsaju Thanks for noticing! I have done it in 3f7a927

@@ -54,6 +44,7 @@ class RecallActivity(activity.Activity):
def __init__(self, handle):
""" Initialize the toolbars and the game board """
super(RecallActivity, self).__init__(handle)
self.max_participants = 1
Copy link
Member

@srevinsaju srevinsaju May 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuiP, I guess; we could remove this instance of self.max_participants if its possible to. then this PR would be perfect!

@chimosky chimosky merged commit 3f7a927 into sugarlabs:master May 15, 2020
@chimosky
Copy link
Member

Review, thanks.

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

Successfully merging this pull request may close these issues.

6 participants