Skip to content

Commit

Permalink
Merge f64376d into 76d4b8e
Browse files Browse the repository at this point in the history
  • Loading branch information
ncilfone committed Feb 18, 2022
2 parents 76d4b8e + f64376d commit 99ea58a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
26 changes: 7 additions & 19 deletions website/docs/Quick-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,23 @@ class BasicConfig:
most_fancy_parameter: List[int]
```

Next let's add two simple function(s) to our script. They both so the same thing but use our parameters in two different
ways.
Next let's add a simple function to our script. The function takes as an argument a `Spockspace` (in this case we type
hint within Python so IDEs can autocomplete), thus we access our defined parameters from the class definition above via
dot notation (just like `Namespaces` as the output from argparsers).

```python
def add_namespace(config):
def add_values(config: BasicConfig):
# Lets just do some basic algebra here
val_sum = sum([(config.fancy_parameter * val) + config.fancier_parameter for val in config.most_fancy_parameter])
# If the boolean is true let's round
if config.parameter:
val_sum = round(val_sum)
return val_sum

def add_by_parameter(multiply_param, list_vals, add_param, tf_round):
# Lets just do some basic algebra here
val_sum = sum([(multiply_param * val) + add_param for val in list_vals])
# If the boolean is true let's round
if tf_round:
val_sum = round(val_sum)
return val_sum
```

Now, we build out the parameter objects by passing in the `spock` objects (as `*args`) to the `SpockBuilder`
and chain call the `generate` method. The returned namespace object contains the defined classes named with the given
`spock` class name. We then can pass the whole object to our first function or specific parameters to our
second function.
and chain call the `generate` method. The returned object contains the defined classes named with the given
`spock` class name which we call a `Spockspace`. We then simply pass `config.BasicConfig` to our function.

```python
def main():
Expand All @@ -77,12 +69,8 @@ def main():
# One can now access the Spock config object by class name with the returned namespace
print(config.BasicConfig.parameter)
# And pass the namespace to our first function
val_sum_namespace = add_namespace(config.BasicConfig)
val_sum_namespace = add_values(config.BasicConfig)
print(val_sum_namespace)
# Or pass by parameter
val_sum_parameter = add_by_parameter(config.BasicConfig.fancy_parameter, config.BasicConfig.most_fancy_parameter,
config.BasicConfig.fancier_parameter, config.BasicConfig.parameter)
print(val_sum_parameter)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion website/docs/addons/tuner/Basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ X_train, X_valid, y_train, y_valid = train_test_split(X, y)

```

The `@spockTuner` decorated classes are passed to the `CSpockBuilder` in the exact same way as basic `@spock`
The `@spockTuner` decorated classes are passed to the `SpockBuilder` in the exact same way as basic `@spock`
decorated classes. This returns a `spock` builder object which can be used to call different methods.

```python
Expand Down
4 changes: 2 additions & 2 deletions website/docs/basics/Saving.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main():
print(config.ModelConfig)
```

### Does the Directory Exit
### Does the Directory Exist

In either case, if the save path does not exist, it will not be created by default. To change this behavior,
set `create_save_path` when creating the builder.
Expand Down Expand Up @@ -139,7 +139,7 @@ def main():
# A simple description
description = 'spock Tutorial'
# Build out the parser by passing in Spock config objects as *args after description
config = CSpockBuilder(ModelConfig, desc=description).save(file_name='cool_name_here').generate()
config = SpockBuilder(ModelConfig, desc=description).save(file_name='cool_name_here').generate()
# One can now access the Spock config object by class name with the returned namespace
# For instance...
print(config.ModelConfig)
Expand Down

0 comments on commit 99ea58a

Please sign in to comment.