Hydra Cheat Sheet - by Codelivly
Hydra Cheat Sheet - by Codelivly
Hydra Cheat Sheet - by Codelivly
Hydra is a powerful password-cracking tool that can perform rapid dictionary attacks against
more than 50 protocols, including SSH, FTP, HTTP, HTTPS, SMB, pop3, IMAP, and many more.
It’s included in Kali Linux by default.
Decorator to
make a function
Basic Invocation @hydra.main()
configurable by
Hydra.
Specifies the
path to the
Config Path Override @hydra.main(config_path="path/to/conf")
configuration
files directory.
Specifies a
particular
Config Name @hydra.main(config_name="config.yaml")
configuration file
Override to use when
calling the
application.
Manually
initialize Hydra
Initialize Config configuration
hydra.initialize(config_path="path")
without Decorator when not using
the @hydra.main
decorator.
Use Python
dataclasses to
Using Structured
@dataclass create structured
Configs
configuration
with type-safety.
Access a
Working with Access Config in configuration
cfg.<param>
Configs Code parameter in
code using cfg .
Access a nested
Access Nested parameter from
cfg.<nested_param>.<sub_param>
Config the configuration
file.
In a config file,
the defaults
keyword allows
Default Config
defaults: composition
Composition
from other
configuration
files or groups.
Append or
Appending/Overriding replace list items
python my_app.py +param=[1,2,3]
Lists in the
configuration.
Dynamically
override a
Override Config from configuration
python my_app.py param=value
Command Line parameter from
the command
line.
Override multiple
python my_app.py param1=value1
Multiple Overrides param2=value2 parameters via
command line.
Replace the
python my_app.py param= values in a list
Override List Items [new_value1,new_value2] from the
command line.
Use YAML
anchors and
Override YAML
&anchor , *alias aliases to reuse
Anchors and Aliases
sections in YAML
config files.
Choose a
configuration
Selecting Config group (e.g.,
Config Groups python my_app.py db=mysql
Groups selecting mysql
configuration in
the db group).
Run a multirun
(grid search),
executing your
Multirun and
Multirun (Grid Search) python my_app.py -m program with
Sweep
multiple
parameter
combinations.
Specify multiple
Specify Multirun values for a
python my_app.py -m param=1,2,3
Values parameter in a
multirun.
Define a custom
output directory
Custom Sweep hydra.sweep.dir=outputs/ for sweep
Directory
outputs during
multiruns.
Control how
Limiting Sweep many multirun
hydra.sweeper.max_batch_size=10
Combinations combinations are
run at once.
Changes the
working
directory for the
Logging and run to a custom
Custom Run Directory hydra.run.dir=outputs/
Output Control directory.
Defaults to a
timestamped
folder.
Configure how
logs are written
Hydra Logging Config hydra/job_logging for jobs,
including custom
logging behavior.
Changes where
Sweep Logging logs are stored
hydra.sweep.dir=logs/
Config during sweep
runs.
Specify custom
Configuring the names for the
hydra.output_subdir=custom_name
Output File Name output
subdirectories.
Integrate custom
Define Custom plugins for
hydra.plugins.<plugin_name>
Plugins extended
functionality.
Manually
initialize Hydra
config in your
Config Manual Config initialize(config_path="path/to/config") program,
Initialization Initialization
required when
not using the
decorator.
Programmatically
load
Programmatic configurations
compose(config_name="config", overrides=
Config Hydra Compose API ["param=value"]) and apply
Composition overrides using
the compose API
in Python.
Show help
message for
Help and available
Hydra Help Command python my_app.py --help
Documentation parameters and
configuration
options.
Displays
command-line
Hydra Command-line python my_app.py -h help with
Multirun Help
multirun
capabilities.
Show verbose
information from
Logging Help python my_app.py hydra.verbose=true Hydra during the
Information
execution
process.
Reference other
configuration
parameters
Using Interpolations ${path.to.some_value} dynamically
in Configs
using
interpolations in
YAML.
Hydra’s
instantiate
function allows
creating
Config Instantiation instantiate(cfg) instances from
config objects
(e.g., initializing
classes from
configurations).
Enable parallel
Optimization
Control Multirun execution for
and hydra.sweeper.search.parallel=true
Concurrency grid search
Performance
(multirun).
Customizes how
Specifying Sweep sweeps are
hydra.sweep.task
Configurations conducted for
different tasks.
Specify custom
Multirun Output Path hydra.sweep.dir=outputs/ directories for
multirun outputs.
Specify
subdirectories to
Save Output for store outputs for
hydra.output_subdir=results/
Multirun Jobs each run during
a multirun
sweep.
This cheatsheet categorizes Hydra's features and provides detailed commands to configure,
manage, and extend Hydra’s functionality.