Repository navigation
Conversation
…unctions as trace methods.
| dataset_id=dataset.dataset_id, model=flow.model, tags=tags, | ||
| trace_content=trace_content, trace_attributes=trace_attributes, | ||
| data_content=data_content) | ||
| run.parameter_settings = OpenMLRun._parse_parameters(flow) |
There was a problem hiding this comment.
Could you, for the future, please format like:
OpenMLRun(
arg1=arg1,
arg2=arg2,
)
This will make reviewing a lot easier.
There was a problem hiding this comment.
Sure, this time I just followed the 'style' from the previous implementation.
| try: | ||
| self.trace = self._generate_trace(trace_attributes, trace_content) | ||
| except ValueError: | ||
| self.trace = None |
There was a problem hiding this comment.
Could you please make the failure more transparent to the user? For example if the trace_attributes and trace_content are empty set self.trace to None as done right now and actually raise the exception otherwise?
| """Generates the arff dictionary for uploading predictions to the server. | ||
|
|
||
| Assumes that the run has been executed. | ||
| def _generate_trace(self, trace_attributes, trace_content): |
There was a problem hiding this comment.
Why did you remove the docstring?
There was a problem hiding this comment.
Because the function changed, it does not return an arff dict but a trace instead. I can however add a docstring for the new function.
| if trace_content is None or len(trace_content) == 0: | ||
| raise ValueError('No trace content available.') | ||
| if len(self.trace_attributes) != len(self.trace_content[0]): | ||
| if trace_attributes is None or len(trace_attributes) != len(trace_content[0]): |
There was a problem hiding this comment.
I assume that trace_attributes is None will happen quite often. Do you maybe mean trace_attributes is not None?
There was a problem hiding this comment.
I meant is None. I wanted to partially controll the error, otherwise when trace_attributes would be None the len function would throw by itself. I can however handle this better
| if self.trace_iterations is None: | ||
| raise ValueError("trace_iterations missing from the trace object") | ||
| # attributes that will be in trace arff | ||
| trace_attributes = [('repeat', 'NUMERIC'), |
There was a problem hiding this comment.
Could you please reformat this as mentioned above?
| evaluation = float(itt[attribute_idx['evaluation']]) | ||
| setup_string = None | ||
| if flag_ss: | ||
| if itt[attribute_idx['setup_string']] != None: |
There was a problem hiding this comment.
Why not is not None?
There was a problem hiding this comment.
you are right, it should be 'is not None.'
|
|
||
| @classmethod | ||
| def _trace_from_xml(cls, xml): | ||
| """Generate trace from xml. |
There was a problem hiding this comment.
Can you generalize this and the method above?
There was a problem hiding this comment.
Generalizing is not easy, since they use different attribute names and also one is a list while the other one is a dictionary. Skipping it for the moment.
There was a problem hiding this comment.
Okay. Could you please add a comment regarding that so that a future maintainer already knows about this.
|
Sure, I am waiting for the response on the issue that I created at OpenML
repo and then I can add the comment along with any possible changes.
…On Thu, Jul 19, 2018, 15:26 Matthias Feurer ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In openml/runs/trace.py
<#482 (comment)>:
> +
+ # if someone needs it, he can use the parameter
+ # fields to revive the setup_string as well
+ # However, this is usually done by the OpenML server
+ # and if we are going to duplicate this functionality
+ # it needs proper testing
+
+ current = OpenMLTraceIteration(repeat, fold, iteration, setup_string,
+ evaluation, selected)
+ trace[(repeat, fold, iteration)] = current
+
+ return cls(None, trace)
+
+ @classmethod
+ def _trace_from_xml(cls, xml):
+ """Generate trace from xml.
Okay. Could you please add a comment regarding that so that a future
maintainer already knows about this.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#482 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXiTK0qb2r6-pewv6-fEoJ4hvvECg8-kks5uIHrqgaJpZM4UtY7g>
.
|
|
The reason why the PR fails is the following: Look at the trace file that I generated using the development branch: https://test.openml.org And the trace file with this specific branch: I see the following differences. The original one has several parameters registered with prefix parameter_ . The new one tries to do the same with setup_string, but this is not the same. I suggest to remove the setup_string, and return to the individual parameter_ fields. I will improve error messages thrown by the evaluation engine (due to a bug, it only showed "java error". This will be better after the latest update is merged). |
This reverts commit a150e27.
|
@janvanrijn could you please use a different branch for these changes? This branch for improving the trace handling for the current version of scikit-learn, which already appears to be quite difficult. |
|
Okay, I fixed the previous error and will now work on removing the new error. Afterwards, this will need a bit of cleanup. |
|
excuse me, wrong branch. i will move them |
|
I will start my review now (in train, wifi seems unstable). Please note additionally that the unit tests fail, all on test cases that seem relevant: |
| if len(content) == 0: | ||
| raise ValueError('Trace content is empty.') | ||
| if attributes is not None: | ||
| if len(attributes) != len(content[0]): |
There was a problem hiding this comment.
Content will be a list, so this will not work.
| trace = OrderedDict() | ||
| attribute_idx = {att[0]: idx for idx, att in enumerate(attributes)} | ||
|
|
||
| required_attributes = ['repeat', 'fold', 'iteration', 'evaluation', |
There was a problem hiding this comment.
maybe declare these in a more prominent place? (static class variable or global variable. Personally I prefer the static class variable)
There was a problem hiding this comment.
Although this seems far fetched, we should also check the attributes array whether there are no attributes that carry any of these names (and add a unit test)
| ---------- | ||
| run_id : int | ||
| OpenML run id | ||
| OpenML run id. |
There was a problem hiding this comment.
I don't care about the tailing dot, but why doesn't our PEP8 check make any noise? ;)
| ('selected', ['true', 'false']), | ||
| ] | ||
| trace_attributes.extend([ | ||
| ('parameter_' + parameter, 'STRING') for parameter in |
There was a problem hiding this comment.
please use the constant (that might have become a static class variable by now) here
| ] | ||
|
|
||
| @staticmethod | ||
| def _from_filesystem(file_path): |
There was a problem hiding this comment.
Just asking, as I can't figure out from the code: Why did you remove this as a private function and add this to a massive generate function? I am (probably) fine with either
There was a problem hiding this comment.
There's no reason, I made this private again.
| arff_dict = OrderedDict() | ||
| data = [] | ||
| for trace_iteration in self.trace_iterations.values(): | ||
| tit_list = [] |
There was a problem hiding this comment.
suggestive variable name, maybe change to something less politically charged.
| for trace_iteration in self.trace_iterations.values(): | ||
| tit_list = [] | ||
| for attr, _ in trace_attributes: | ||
| if attr.startswith('parameter_'): |
| attribute_idx = { | ||
| att[0]: idx for idx, att in enumerate(arff_obj['attributes']) | ||
| } | ||
| required_attributes = [ |
There was a problem hiding this comment.
From here on, the code seems highly similar to the static function that you pulled in the generate function. Unless there is any good reason, why not put the duplicate code in a (static) functions?
| att_name = trace_attribute_list[att_idx][0] | ||
| # They no longer start with parameter_ if they come from | ||
| # extract_arff_trace! | ||
| if att_name.startswith("parameter_"): |
There was a problem hiding this comment.
please use the constant (which is a static class variable by now)
janvanrijn
left a comment
There was a problem hiding this comment.
I really like this PR! I know there are a lot of changes requested, but once these are resolved this highly uncomplicates the code.
|
@janvanrijn @ArlindKadra I updated this PR based on your suggestions. Please check again. |
janvanrijn
left a comment
There was a problem hiding this comment.
Note that you left some TODO's in the unit tests as well.
This is a first step towards more extensive unit tests for to/from xml for runs, checking that the uploaded xml file and the xml file generated from a downloaded run are equal.
Requires more extensive rewrites of how traces are generated to check them as well.
Needs to be rebased on #481 to not choke on wrong sorting in the xml file.