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

Local datasets #87

Merged
merged 104 commits into from
Jan 30, 2017
Merged

Local datasets #87

merged 104 commits into from
Jan 30, 2017

Conversation

grdw
Copy link
Contributor

@grdw grdw commented Jan 26, 2017

All things related to local datasets for Atlas


Contains part of #88

Gerard Westerhof and others added 30 commits December 7, 2016 10:49
Persisting the current graph to a yaml file

Open comments from #58 will be adressed in separate pull request.
- Dataset is the new base class
- DerivedDataset and FullDataset inherit from Dataset
Also create implementations of Exporter:
 - FullExporter (corresponds to old Exporter)
 - EssentialExporter (corresponds to old GraphExporter)

Ref https://github.com/quintel/internal/issues/5#issuecomment-265103928
Ref https://github.com/quintel/internal/issues/5#issuecomment-265120551
- Avoid using send()
- Merge in new_attributes after scaled_attributes
@codecov-io
Copy link

codecov-io commented Jan 26, 2017

Codecov Report

Merging #87 into master will increase coverage by 1.4%.

@@            Coverage Diff            @@
##           master      #87     +/-   ##
=========================================
+ Coverage   92.11%   93.52%   +1.4%     
=========================================
  Files          53       69     +16     
  Lines        1458     1729    +271     
=========================================
+ Hits         1343     1617    +274     
+ Misses        115      112      -3
Impacted Files Coverage Δ
lib/atlas/production_mode.rb 100% <ø> (ø)
lib/atlas/exporter.rb 100% <ø> (ø)
lib/atlas/node/central_producer.rb 75% <ø> (+36.53%)
lib/atlas/runtime.rb 97.05% <100%> (ø)
lib/atlas/exporter/full_exporter.rb 100% <100%> (ø)
lib/atlas.rb 100% <100%> (ø)
lib/atlas/carrier.rb 100% <100%> (ø)
lib/atlas/scaler/graph_scaler.rb 100% <100%> (ø)
lib/atlas/runner/set_rubel_attributes.rb 100% <100%> (ø)
lib/atlas/csv_document.rb 100% <100%> (+2.7%)
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a67953...8d63562. Read the comment docs.

@grdw grdw requested a review from antw January 26, 2017 15:26
@grdw
Copy link
Contributor Author

grdw commented Jan 27, 2017

@antw can this be merged? 👼

Copy link
Contributor

@antw antw left a comment

Choose a reason for hiding this comment

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

Nice work @grdw and @ploh!

I left a couple of comments, but they're all very minor; mostly style-related rather than actual problems.


validates :scaling, presence: true

validate :base_dataset_exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these methods be named "validate_something" for consistency with existing validation methods in Edge, Input, Node, etc. It helps to differentiate validation methods from "normal" methods.

Copy link

Choose a reason for hiding this comment

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

👍

#######
def graph
@graph ||=
precomputed_graph? ? dataset.graph : GraphBuilder.build
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be split across two lines; the whole thing would be < 80 characters.


private

# ActiveDocument.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "ActiveDocument" mean here? I suspect copy/paste from here?

@@ -0,0 +1,69 @@
module Atlas
class Scaler
Copy link
Contributor

Choose a reason for hiding this comment

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

Could do with some documentation.

value: value,
base_value: base_value,
area_attribute: 'number_of_residences',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation and trailing commas:

scaling: {
  value:          value,
  base_value:     base_value,
  area_attribute: 'number_of_residences'
}

result[attr] = Util::round_computation_errors(value * @scaling_factor)
end
end
result
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace with each_with_object?

def scale
  SCALEABLE_AREA_ATTRS.each_with_object({}) do |attr, data|
    if value = @base_dataset[attr]
      data[attr] = Util::round_computation_errors(value * @scaling_factor)
    end
  end
end

Copy link

Choose a reason for hiding this comment

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

Personally, I still do not really like each_with_object. My version here looks more readable to me (except map instead each, that is a mistake of course). But I am fine either way

@@ -0,0 +1,63 @@
module Atlas
class Dataset::DerivedDataset < Dataset
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you guys feel about naming these two new classes simply "Derived" and "Full"? "Dataset" already appears in the module tree, and it would shorten the .ad file names ("datasets/nl/nl.full.ad" instead of "datasets/nl/nl.full_dataset.ad").

It would also be more consistent with Node subclasses (although I think consistency is not super-important in this case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me, what do you think @ploh?

Copy link

Choose a reason for hiding this comment

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

Yes! Very much in favour of this!
The current names date back to when we did not have a proper class hierarchy for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I pick this up? -> #88

@@ -0,0 +1,72 @@
module Atlas
class GraphDeserializer
def self.build(graph_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • If build is the only public way to use this class (i.e. you don't intend for third-party code to ever run new(...).build_graph), you might want to add private_class_method :new: this will enforce that users of this class must use call.

    This also applies to AreaAttributesScaler and TimeCurveScaler.

  • A little documentation describing what the graph_hash parameter is – and what the method returns – would be a nice addition.

Copy link

Choose a reason for hiding this comment

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

👍

(Sorry for these emoji only remarks. The mobile version does not seem to allow the direct emoji reactions)

Gerard Westerhof added 2 commits January 30, 2017 10:52
- Renaming validation methods for derived dataset class
- Removing line of comment
- Removing newline
class Scaler
UNSCALED_ETENGINE_DATA_FILES = %w( fce load_profiles network ).freeze

def initialize(base_dataset_key, derived_dataset_name, number_of_residences, base_value = nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ploh Why is base_value used as the 4th optional argument? It won't be picked up by rake scale as far as I know.

Copy link

Choose a reason for hiding this comment

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

But by the scenario migration rake task in etengine that i am going to push, hopefully tomorrow

+ Add documentation about the
@grdw
Copy link
Contributor Author

grdw commented Jan 30, 2017

@antw I fixed most comments. Some of them seem like nice to have's and could maybe be put into issues I think. If there's time we'll fix them but it would be nice if this can be merged today (no pressure).

@antw antw merged commit 8de31c5 into master Jan 30, 2017
@antw antw deleted the local-datasets branch January 30, 2017 14:32
@antw
Copy link
Contributor

antw commented Jan 30, 2017

Merged it! Nice work @grdw and @ploh! 🎉

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.

4 participants