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

Upload network to server? #222

Open
Nyquixt opened this issue Oct 26, 2019 · 16 comments
Open

Upload network to server? #222

Nyquixt opened this issue Oct 26, 2019 · 16 comments

Comments

@Nyquixt
Copy link

Nyquixt commented Oct 26, 2019

So, I tried to set up the LZ server locally. I managed to get everything done (I hope) except for the uploading network part. What I did was:

  • gzip my network txt file (txt -> gz)
  • change its name to best-network.gz
  • use curl -F '[email protected]' -F 'training_count=0' -F 'key=auth_key' http://localhost:8080/submit-network
  • copy best-network.gz into leela-zero-server/network/ directory
  • change const Qstring server_url = "https://zero.sjeng.org/" to "http://localhost:8080/"

...and still got this error about mismatching in hash.
BTW, is a code of 52 I got from curl bad?
Thanks in advance!
curl52
hashnomatch

@roy7
Copy link
Collaborator

roy7 commented Oct 27, 2019

Sounds similar to the problem in #217 but @Superkidd didn't actually say how he fixed it in the end.

@roy7
Copy link
Collaborator

roy7 commented Oct 27, 2019

BTW you don't need to rename to best-network.gz and it doesn't matter if you do. The server names each uploaded network with the hash, and stores it under networks/. For a net to become 'best' and promoted by server, you need to have it do a match and then the match successfully pass/promote the challenger. For the very first setup of the server you need to manually copy a network into networks/ and name it best-network.gz.

@Nyquixt
Copy link
Author

Nyquixt commented Oct 28, 2019

@roy7 I did what you told me too. Yet, the calculated hash even with a different network uploaded is still 3ba11708... Also, I followed a more detailed instruction on how to set up the server on https://github.com/sai-dev/sai-server and still got the error. Is there anything else to change beside the QString url_server in autogtp? Plus, attached is the server log when I curled the network.
Screenshot from 2019-10-28 16-00-55
Screenshot from 2019-10-28 16-04-34

@roy7
Copy link
Collaborator

roy7 commented Oct 28, 2019

Would you look at the download network with cat or a text editor and see if looks like a valid net? What's its file size? I'm guessing it isn't actually downloading a network so you don't see the hash changing. I'm suspecting it's downloading an error message or a null file or something?

The server error about trying to access 'count' of a null variable, is because you have no games at all. Once a game exists I guess that goes away. Try changing line 611 from "set.training_count = totalgames.count;" to "set.training_count = (totalgames ? totalgames.count || 0);"

That should avoid crashing on upload of network with zero games played, and thus get the game into the database...

@roy7
Copy link
Collaborator

roy7 commented Oct 28, 2019

I've updated master branch to have everything in next branch, which could possibly have an effect. Some old next changes were related to gzip_hash I think.

Yes, all the code that adds "hash_gzip_hash" field in the selfplay packet from server (missing in your log above) was only in next branch not master branch. I've merged all of next into master now.

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

@gcp When autogtp downloads a network, and it uses a URL like networks/hash.gz, we have a setting in the web server that intercepts the networks/ path don't we? Because I'm not seeing a handler anywhere in the server code to serve binary files requested under the networks/ end point. Doh?

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

This I think would be the key?

sai-dev@26c2ab8

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

SAI team fixed this bug last year, who knew? sai-dev@02f7f10

@gcp
Copy link
Member

gcp commented Oct 29, 2019

When autogtp downloads a network, and it uses a URL like networks/hash.gz, we have a setting in the web server that intercepts the networks/ path don't we?

Yes that's handled directly by the webserver without involving node.js. Improves the memory usage.

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

Thanks. I never documented that so it's why some people have failed to get the server working in the past, doh!

@gcp
Copy link
Member

gcp commented Oct 29, 2019

Currently there's even extra tricks to "fall back" to leela.online-go.com for older networks.

nginx config:

    location /networks {
        fancyindex on;
        fancyindex_default_sort date_desc;
        alias /home/jroy/code/leela-zero-server/network;
        try_files $uri @storage;
    }

    location @storage {
        expires 30s;
        return 301 https://leela.online-go.com$request_uri;
    }

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

Thanks, good to have that documented someplace. :) Sadly it's taken over a year for me to fix this by default for new people trying to run local servers.

@roy7
Copy link
Collaborator

roy7 commented Oct 29, 2019

Ok @Nyquixt check out #227

@Nyquixt
Copy link
Author

Nyquixt commented Oct 30, 2019

@roy7 nice!

@Nyquixt
Copy link
Author

Nyquixt commented Oct 30, 2019

BTW, why is 11 is on the second line of /best-nerwork-hash response?

@roy7
Copy link
Collaborator

roy7 commented Oct 30, 2019

Might be an old protocol version number or something? I'm not actually sure any more lol.

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

3 participants