-
Notifications
You must be signed in to change notification settings - Fork 11
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
Issue #167: curl step #245
Conversation
e72048f
to
459c94c
Compare
@marcghaly can you please rebase this, was a few clashes. Comments in the pr |
8bfc6c6
to
d31019d
Compare
Hi @brendanheywood, I have fixed issues above, path issue and Regards, Marc |
@marcghaly Sure thing. I can take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @marcghaly I've done a pass of the code. I haven't tested the functionality of the code yet but I'll do that shortly.
Doing a bit more functional testing (from the UI):
|
To refine this a little, if curl downloads a file into the local scratch dir then this should NOT be considered having a side effect. It is not changing state outside of its own temporary memory and storages. If that file was then copied in another step to path which was outside the scratch dir then that would have side effects. So in theory the only time a curl step should have side effects is if the remote host is marked as changing state @marcghaly this is a little tricky as the scratch directory pr hasn't landed yet: https://github.com/catalyst/moodle-tool_dataflows/pull/252/files Also if you are in dry run mode, and normally you are curling a remote api and it grabs a file which is then used in later steps, then our workflow will now abort in dry run mode when the later step can't find the file it needs. So what we need is an additional setting which is the contents of the file it will write in dry run mode when it will not actually do the real curl call. This can just be a textarea or a file upload which ever is easiest. |
I'm having trouble referencing the response from a subsequent step for when the destination path is not set. e.g. using the expression To ease with testing, are you able to export the dataflow you've been using to test with? |
Hi @keevan, Thank you for the review, I made appropriate changes - are you able to use data from a former step this way This is the yml file I am using :
Regards, Marc |
cad2ac8
to
632295d
Compare
685280f
to
1261d72
Compare
Hi @keevan, I have fixed points cited above could you have another look if possible ? Thank you Marc |
Hi @marcghaly , one other thing. I would like each type of step to have at least one unit test of some sort. Are you able to include one for this step please? I'll continue the review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($config->method != 'get') { | ||
$this->hassideeffect = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason this field needs to be updated?
In either case, if it's needed I think the handling for this doesn't need to be here in particular, and can join the snippet further above where it's initially set. This should be deterministic before the curl is run, so should be further above before any actual handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If method is post
or put
it will have side effects but setting it above will prevent the execution of the curl request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not following. I've tried moving the if block up and making it look like so, and it seems to work okay:
$this->hassideeffect = !empty($config->sideeffects);
if ($config->method != 'get') {
$this->hassideeffect = true;
}
The other question was whether or not $this->hassideeffect was used anywhere in this step in particular, since it's only used for display purposes and an example is located here https://github.com/catalyst/moodle-tool_dataflows/blob/MOODLE_35_STABLE/classes/local/step/flow_step.php#L109
I think if it can change, based on configuration values, then perhaps the has_side_effect function in base_step needs to be overriden in the connector_curl step, to include the extra checks. It doesn't seem like the block I mentioned above does anything in particular, but if you think it should could you please clarify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion, you are right it is working well when moved up, I tried it with older code - it is not used anywhere else in this step, I am unsure about what checks need to be done and why it should be overridden though
8afe841
to
ff7f1a2
Compare
Hi @keevan, I have added unit tests and fixed issues - just unsure concerning the API I am using, should it be like a "mock api" so it is always "online", this is also rebased over last master. Regards Marc |
Hi Marc, I noticed there are various unaddressed comments on the files tab. Can you please respond to those open issues. Also regarding the API test. It's much more reliable (and fast) if we mock the response instead of relying on a third party. There might be examples in core that do this already. From a high level, I'm expecting a combination of test things like:
|
e911488
to
b489a1f
Compare
Hi @keevan, I have updated unit tests let me know status concerning side effects issue Regards, Marc |
HI @marcghaly, could you please
With regards the side effects setting of state. I think though it's not used currently, it might see some use later on, but it's quite harmless to leave in there. If anything, it would be moved to a But for now, I'm quite happy with what it's currently demonstrating so if there are any bugs / issues once used with the json reader step then we'll iron those out then as well. Thanks @marcghaly. |
331a461
to
4119718
Compare
Hi @keevan, points above have been fixed - branch is rebased over latest main one. Regards, Marc |
4119718
to
a54fd41
Compare
a54fd41
to
d98dd46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, there'll be more adjustments made as we go along since there are other things available but this is good to be merged in.
Hi @brendanheywood,
This is PR for issue #167,
Regards,
Marc
--
Resolves #167