-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Submitting solutions direct from Pharo #96
Comments
First the download, for comparison.
This created hello-world folder holding four files.
Now Submitting...After making edits, uploading two files since one is not informative enough.
|
Haven't bumped into the HTTP PATCH verb before. Some info... "It is important to realize that the request entity to PATCH is of a different content-type than the entity that it is modifying." [ref] |
Just noting, running the identical command without any edits returns a bad status. The full diff shown here, and just the important part below...
Making an edit to just one of the files submitted then gives good status...
|
I've been hacking away at a solution in the playground to get a rough idea of what works. I'm close but not quite there yet. This is all new territory for me. Here is my hacked together submitting client: fileName := 'path to a Tonel file'.
client := ZnClient new
http;
host: 'api.exercism.io';
method: 'PATCH';
headerAt: 'Authorization' put: 'Bearer ', apiToken;
contentType: ZnMimeType applicationOctetStream;
contentType: ZnMimeType multiPartFormData;
headerAt: 'Content-Disposition' put: (ZnMimeType main: 'form-data' sub: '' parameters: { 'name' -> 'files[]'. 'filename' -> fileName } asDictionary). Not quite working yet as I get the error: |
Update on the above. I've got one step further and the client is now looking like this: client := ZnClient new
entity: (ZnMultiPartFormDataEntity new addPart: 'boundary=f7b01eaa5fcf167c2094054c167fd0685b596a361e868587b0095593730d');
http;
host: 'api.exercism.io';
method: 'PATCH';
headerAt: 'Authorization' put: 'Bearer ', apiToken;
contentType: ZnMimeType applicationOctetStream;
contentType: ZnMimeType multiPartFormData;
headerAt: 'Content-Disposition' put: (ZnMimeType main: 'form-data' sub: '' parameters: { 'name' -> 'files[]'. 'filename' -> fileName } asDictionary);
patch. Not working yet. I'm only just discovering what multipart form data entities are. |
Please excuse the rambling, but I've had an exciting crash course on multipart form data entities and I'm finally figuring out parts on the Zinc library. Our client looks like this: apiToken := (STON fromString: 'path to user.json file' asFileReference contents) at: #token.
fileName := 'path to a exercise file of Tonel format'.
multiPartFormDataEntity := ZnMultiPartFormDataEntity new
addPart: (ZnMimePart fieldName: 'files[]' fileNamed: fileName).
client := ZnClient new
entity: multiPartFormDataEntity;
http;
host: 'api.exercism.io';
method: 'PATCH';
headerAt: 'Authorization' put: 'Bearer ', apiToken.
client patch;
response. Helpfully the Zinc library handles all the finer details of boundaries, content types and dispositions etc. automatically. The response on this one is 404 so it's not quite right yet. I'll keep looking into it an hopefully have something more tomorrow. |
@samWson, looks like good progress. From my experience reported exercism/cli#732 I believe that service doesn't work with HTTP. Try HTTPS, |
I've changed the scheme to HTTPS, but it is still a 404 response so something else is bad. Here is the transcript output:
I've tweaked around with the Authorization, using the wrong token, and hard coding the correct token, just to be sure that wasn't the problem. I've made sure that the URI is using HTTPS. I'm not sure what else could be wrong here. |
I've had a pretty good go at this and am also stuck. I've now got the Exercism website up and running locally per https://github.com/exercism/website to facilitate observing the CLI's wire transfer in operation. I've successfully signed up to it with my github account, but it seems there is no track data loaded in the database. http://lvh.me:3000/my/tracks tells me I have 0 tracks and searching for python returns empty response. I've inquired how to load track data into into the database. I presume I should configure the CLI like this...
Aside: I actually found it easier to not use docker which I struggled with, since I'm not familiar with it. Ended up running it under Windows 10 Subsystem for Linux Ubuntu 16.04 and accessing it from Chrome on Windows side. |
kytrinyx> We are doing a multipart fileupload. Here's a test request:
@kytrinyx, thx for the sample request above (I copied here from the other closed thread). Can you confirm the use of POST and also the root "/" with no path. Several posts above (just below the "Now Submitting..." heading ) you can see that the CLI |
@samWson, I picked up that you're also a Ruby guy. This looks related to loading data into the local web site, just don't know how to invoke it -- any clue... |
I was having trouble redirecting the CLI to my local Exercism website, then found the correct form was... |
One more hurdle I had to get over, WireShark doesn't work on loopback, so I had to get my local server and the client running on different machines. Now Yay! I managed to capture HTTP off the wire for a submit (regardless of empty database)
Note the extra 'api' string before the '/v1' shown in the wire capture Now I discover that... But within Pharo, if I do...
I then reconfirmed that the following worked... @kytrinyx, @iHiD, I'm confused. Maybe https://github.com/exercism/website which I installed locally is the old site? |
Here is where I'm up to. The request capture from the wire for following...
shown below is very close to @kytrinyx sample a few posts above,
but gets a response...
Differences to CLI client appear to be:
Difference to @kytrinyx sample a few posts above:
|
Shoot, no, that was from when I was working out the original request and had made a stand-alone app that only had one endpoint that accepted multi-part file uploads. So sorry about that rabbit hole! |
but I'm getting...
The --api value needs to be a URL you can hit in your browser. Are you able to go to http://lvh.me:3000? |
You're right that this uses |
Ah, yes. We need to add documentation about this. The production API is delivered from |
No, this is the new site. The error message is the one that you get if you hit an endpoint that is not valid for the API. So for example: http://api.exercism.io/api/v1/solutions/latest (notice that it has both api.exercism.io and the |
When I was originally developing the client I tested with both Authorization Bearer and Authorization Token and both worked. |
I'm really not sure what is causing the 500 error when you hit production as described in #96 (comment). I can't find that error in our logs. |
@bencoman at a guess it looks like it is for keeping the language tracks synchronized on the website (you wouldn't need to auto approve hello world on the users computer right?). I get lost where the code reaches out of the class with For invoking it do you mean at the Rails console using the class itself? The class method |
Nice one @bencoman - but the question is, is this a bug in that Pharo method for ZnMimePart - or is this a parsing bug in the exercism server? The mozilla docs for content-disposition don't mention a space is required, just that all parameters are separated by a ';'. (although all their examples show a space after each parameter) We can of course get Pharo fixed (or add our own extension method to workaround this) - but it seems strange that space is required. I guess we should ask sven. |
@bencoman cool. I've gone through your steps above and now I finally understand. I see the issue that we don't know where the bug is, Pharo or Exercism. I suggest in the short term we do a one time fix to our own code to get around this. That way we can keep moving forward and it's not hard to reverse if we need to. |
I think we can add our own extension method (with an ex prefix) as I think we call it vs the library right? I have a long flight coming up in a few days, and can look at replacing the shell out code. Looks pretty easy given Ben’s example. Or is one of you guys itching to do it? |
Agree on short term action - we should adopt that method by changing its method-protocol to "*ExercismTools". Now with the ancillary difficulties failing to get the Dev Local Website going under WSL, and doing it again on an old Linux box and then experimenting/analysing the Exercism CLI HTTP traffic, I burnt four FT days on it when I should have been working on something else. So if someone could do the work to implement my POC that would be great. The final piece of the puzzle of how/where to store the solution metadata between the Download and the Submit has one option implemented in PR #104. |
Exercism requires space in MimePart Content-Disposition This patches the `ZnMimePart` class to get around our 500 error problems when submitting exercises over HTTP for #96.
I'm going to have a go at building this solution from the |
Go for it - I started to have a quick look, but didn’t get enough un-interupted time to get very far. I think you may need to push up some variables from the the other DownloadCommand that Ben refactored this too.
I may have a look at some point (probably in 5 days when I have a long flight and can mull it over) - but lets see how far you get too, and we can compare notes.
I think there is the question about storing some meta data stuff - that needs to be stored somewhere as a property on something - but don’t let that distract you yet.
Tim
… On 19 Sep 2018, at 00:02, Samuel ***@***.***> wrote:
I'm going to have a go at building this solution from the ExercismSubmit class stub. It's pushing my skills so I will probably make a few work in progress pull requests when I need help. Conveniently I've been building a lot of command pattern classes at work recently so hopefully I can make something that works.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#96 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFS919uP4679cNez8tk4N2-cqbREOc7gks5ucewAgaJpZM4WcJYt>.
|
Cool, thanks Sam.
To provide that info, I've merged PR #104 into After pulling down the latest
Now there are a few cases that may be useful: |
After that merge, you can now do... |
@bencoman @macta related to using the UI to submit exercises, the message (writer := ExTonelWriter new)
packageDir: (submissionDirectoryRef relativeTo: trackDirectoryRef) exPathString;
sourceDir: trackDirectoryRef;
writeSnapshot: packageOrTag snapshot. I'm wondering at this point if it is a method we made ourselves and have accidentally deleted it, or my image is missing some code from a branch or just somehow is not up to date. The same code is also used in |
Sorry guys I’ve been off the grid (turns out the outback has limited 3G ;) That method rings a bell - TonelWriter is quite convoluted and I recall we had to do do some nasty overriding to coerce it to even do stuff. I will check as I filed a PR with Tonel. |
I've been looking around over the last week on this and I had a thought. We had to make some changes to @bencoman since it looks like your going to be busy for the time being, if you don't mind I'll make a PR for the changes to After that I'll keep looking around to try and make some more progress. |
On Sat, 3 Nov 2018 at 14:54, Samuel ***@***.***> wrote:
I didn't include the changes to TonelWriter in my last commit for that
PR. They are summarised here
<#110 (comment)>.
I did my last commit to that same PR. To get it working out of the box in
a fresh image I added our required Tonel changes as an extension...
227172f#diff-e9dc21d4b8fe3f8ba613c5b452e4ed04R1
I've started discussion with Tonel guys about it...
pharo-vcs/tonel#55
@bencoman <https://github.com/bencoman> since it looks like your going to
be busy for the time being
Yes, my day job it stretching me and I'm doing a lot of home reading to
catch up my knowledge of hundreds of pages of standards.
I'd be grateful if you can keep plugging away at it.
|
It turns out the fix for I've pushed PR #112 which should fix submitting exercises from the GUI. If there is any I think we finally may have a working product for all three operating systems now. I'm going to take a break from coding for the next few days. We have a lot of issues open and I'd like to go back and review them so we can keep this project pointed in the right direction. |
#112 is merged. I think this issue is finally fixed. We should have a working submit solution for all operating systems now. |
btw, tracked the issue back to Rack, a Ruby library used by Sinatra, that is used by Exercism. |
Following on from success with downloading exercises directly into Pharo IDE, now need to work on submitting solutions.
exercism --verbose submit hello_world.py hello_world_test.py
provides sample headers, but not sample content sent to the server. Tried to observe this with Wireshark, but having trouble configuring the CLI client to use HTTP.Asked for some help with that at CLI Issue 732.
The text was updated successfully, but these errors were encountered: