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

Remove Unused Dependency: Netaddr #1257

Merged
merged 1 commit into from
Sep 12, 2023
Merged

Conversation

gdrosos
Copy link
Contributor

@gdrosos gdrosos commented Aug 12, 2023

Summary

This pull request removes the unused dependency netaddr from the requirements.txt configuration file. The removal of this dependency is a finding from ongoing research aimed at identifying and eliminating code bloat within software projects.

Rationale

The netaddr library was first integrated into the project as per 0b69f39, to support its usage in lib/jnpr/junos/cfg/srx/ab_finder.py. However, as of 8f4c131, the ab_finder.py file has been removed from the project, rendering the associated dependency redundant. Despite its removal from the source code, netaddr remained listed as a requirement in the project's configuration file. Removing this unused dependency reduces the overall footprint of the application, mitigating potential security risks, and simplifying the dependency management process.

Changes

  • Removed the netaddr dependency from requirements.txt.

Impact

  • Reduced Package Size: Omitting this unused dependency will reduce the overall size of the installed packages.
  • Simplified Dependency Tree: Reducing dependencies simplifies maintenance and can expedite installation.

@gdrosos
Copy link
Contributor Author

gdrosos commented Aug 27, 2023

Hello @dineshbaburam91, @chidanandpujar

I hope this message finds you well. We are currently engaged in a research project focused on optimizing projects by identifying and eliminating unnecessary dependencies. Your insights and expertise as maintainer would greatly contribute to our research efforts.

Could you please take a moment to review the changes proposed on this PR? Your input would be highly valuable to us.

Thank you for your consideration!

@chidanandpujar
Copy link
Collaborator

chidanandpujar commented Sep 7, 2023

Hi @gdrosos
Thanks for the code changes .
Could you please run the UT/Functional tests with your changes and share the results here .

Thanks .

Copy link
Collaborator

@chidanandpujar chidanandpujar left a comment

Choose a reason for hiding this comment

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

Looks to be fine , please run the functional/Unit tests .

@gdrosos
Copy link
Contributor Author

gdrosos commented Sep 7, 2023

Hello @chidanandpujar, thanks for the response!
Are there any specific instructions for running the tests?

@chidanandpujar
Copy link
Collaborator

Hello @chidanandpujar, thanks for the response! Are there any specific instructions for running the tests?

Hi @gdrosos
Thanks ,
Please refer the steps
https://github.com/chidanandpujar/documentation_steps/blob/main/nose_tests_setup

Thanks

@gdrosos
Copy link
Contributor Author

gdrosos commented Sep 7, 2023

Thanks @chidanandpujar, please find bellow first the unit tests:
nosetests -v *

Ran 828 tests in 9.771s

FAILED (errors=5, failures=9)

nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit

-------------------------------------------------------------------------
TOTAL                                                  5519    345    94%
----------------------------------------------------------------------
Ran 825 tests in 11.639s

OK

nosetests -v --with-coverage --cover-package=jnpr.jsnapy --cover-inclusive -a unit

TOTAL                                                                                                   6069    895    85%
----------------------------------------------------------------------
Ran 825 tests in 11.626s

OK

Regarding the functional tests, should I be in the tests/functional directory to run them?

nosetests -v --with-xunit --xunit-file=functionaltests.xml --with-coverage --cover-package=jnpr.junos --cover-xml --cover-inclusive --cover-erase test_config.py test_core.py test_exception.py test_file_ftp.py test_file_scp.py test_route_table.py test_rpc.py test_route_table.py test_shell.py test_table_present.py test_telnet.py test_utils_sw.py

With the above command I get:

Ran 10 tests in 0.018s

FAILED (errors=12)

Moreover, with the command:

nosetests -v --with-xunit --xunit-file=functionaltests.xml --with-coverage --cover-package=jnpr.junos --cover-xml --cover-inclusive --cover-erase test_utils_file_system
I get:

Failure: ModuleNotFoundError (No module named 'test_utils_file_system') ... ERROR

======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'test_utils_file_system')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/loader.py", line 407, in loadTestsFromName
    module = resolve_name(addr.module)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/util.py", line 312, in resolve_name
    module = __import__('.'.join(parts_copy))
ModuleNotFoundError: No module named 'test_utils_file_system'

----------------------------------------------------------------------
XML: /home/gdrosos/forks/py-junos-eznc/tests/functional/functionaltests.xml
/home/gdrosos/.local/lib/python3.9/site-packages/coverage/inorout.py:519: CoverageWarning: Module jnpr.junos was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
Traceback (most recent call last):
  File "/home/gdrosos/.local/bin/nosetests", line 8, in <module>
    sys.exit(run_exit())
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/core.py", line 118, in __init__
    unittest.TestProgram.__init__(
  File "/usr/lib/python3.9/unittest/main.py", line 101, in __init__
    self.runTests()
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/core.py", line 66, in run
    result.printErrors()
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/result.py", line 110, in printErrors
    self.config.plugins.report(self.stream)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/nose/plugins/cover.py", line 183, in report
    self.coverInstance.stop()
  File "/home/gdrosos/.local/lib/python3.9/site-packages/coverage/control.py", line 967, in report
    return reporter.report(morfs, outfile=file)
  File "/home/gdrosos/.local/lib/python3.9/site-packages/coverage/summary.py", line 43, in report
    for fr, analysis in get_analysis_to_report(self.coverage, morfs):
  File "/home/gdrosos/.local/lib/python3.9/site-packages/coverage/report.py", line 68, in get_analysis_to_report
    raise NoDataError("No data to report.")
coverage.exceptions.NoDataError: No data to report.

@gdrosos
Copy link
Contributor Author

gdrosos commented Sep 8, 2023

Hello @chidanandpujar, is there anything else you need from my side in order to move this PR forward?

@chidanandpujar
Copy link
Collaborator

Hi @gdrosos
Thank you
UT tests are working fine your code changes , we need to check functional test cases .
I will check and update .

Thanks

@chidanandpujar
Copy link
Collaborator

chidanandpujar commented Sep 12, 2023

Hi @gdrosos
Thanks,
Functional tests looks to be working fine .

nosetests -v --with-xunit --xunit-file=functionaltests.xml --with-coverage --cover-package=jnpr.junos --cover-xml --cover-inclusive --cover-erase test_config.py test_core.py test_exception.py test_file_ftp.py test_file_scp.py test_route_table.py test_rpc.py test_route_table.py test_shell.py test_table_present.py test_telnet.py test_utils_sw.py 
Failure: ModuleNotFoundError (No module named 'skip_version') ... ERROR
test_device_cli (tests.functional.test_core.TestCore) ... /root/pyez_netaddr/py-junos-eznc/lib/jnpr/junos/device.py:724: RuntimeWarning: 
CLI command is for debug use only!
Instead of:
cli('show version')
Use:
rpc.get_software_information()

  warnings.warn(warning_string, RuntimeWarning)
ok
test_device_facts (tests.functional.test_core.TestCore) ... ok
test_device_get_timeout (tests.functional.test_core.TestCore) ... ok
test_device_open (tests.functional.test_core.TestCore) ... ok
test_device_rpc (tests.functional.test_core.TestCore) ... ok
test_device_rpc_format_text (tests.functional.test_core.TestCore) ... ok
test_device_rpc_normalize_true (tests.functional.test_core.TestCore) ... ok
test_device_rpc_timeout (tests.functional.test_core.TestCore) ... ok
test_device_set_timeout (tests.functional.test_core.TestCore) ... ok
test_load_config (tests.functional.test_core.TestCore) ... ok
test_FS_checksum (tests.functional.test_exception.TestUtilFs) ... ok
test_config_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_device_rpc_timeout (tests.functional.test_exception.TestUtilFs) ... ok
test_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_exception_commitError (tests.functional.test_exception.TestUtilFs) ... ok
test_exception_commitError_commitCheck (tests.functional.test_exception.TestUtilFs) ... ok
test_exception_severity (tests.functional.test_exception.TestUtilFs) ... ok
test_load_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_lock_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_rescue_action (tests.functional.test_exception.TestUtilFs) ... ok
test_rollback_id (tests.functional.test_exception.TestUtilFs) ... ok
test_rpc_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_rpc_exist (tests.functional.test_exception.TestUtilFs) ... ok
test_rpc_load_extension (tests.functional.test_exception.TestUtilFs) ... /root/pyez_netaddr/py-junos-eznc/lib/jnpr/junos/utils/config.py:550: ResourceWarning: unclosed file <_io.TextIOWrapper name='./sample/load_fail.html' mode='r' encoding='UTF-8'>
  rpc_contents = open(kvargs["path"], "r", newline=None).read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
test_rpc_no_format (tests.functional.test_exception.TestUtilFs) ... ok
test_rpc_set_override (tests.functional.test_exception.TestUtilFs) ... ok
test_unlock_exception (tests.functional.test_exception.TestUtilFs) ... ok
test_scp_put (tests.functional.test_file_scp.test) ... ok
test_scp_put_file_get (tests.functional.test_file_scp.test) ... /root/pyez_netaddr/py-junos-eznc/lib/jnpr/junos/utils/scp.py:46: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  spec = inspect.getargspec(self._user_progress)
ok
test_device_rpc (tests.functional.test_rpc.TestCore) ... ok
test_device_rpc_format_text (tests.functional.test_rpc.TestCore) ... ok
test_device_rpc_timeout (tests.functional.test_rpc.TestCore) ... ok
test_display_xml_rpc (tests.functional.test_rpc.TestCore) ... ok
test_getConfig (tests.functional.test_rpc.TestCore) ... ok
test_interface_terse_text (tests.functional.test_rpc.TestCore) ... ok
test_route_information (tests.functional.test_rpc.TestCore) ... ok
test_rpc_get_interface_information_mtun (tests.functional.test_rpc.TestCore) ... ok
test_shell_run (tests.functional.test_shell.test) ... ok
test_arp_table (tests.functional.test_table_present.test_table) ... ok
test_arp_table_to_json (tests.functional.test_table_present.test_table) ... ok
test_table_get_value (tests.functional.test_table_present.test_table) ... ok

======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'skip_version')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/pyez_netaddr/venv/lib/python3.9/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/root/pyez_netaddr/venv/lib/python3.9/site-packages/nose/loader.py", line 417, in loadTestsFromName
    module = self.importer.importFromPath(
  File "/root/pyez_netaddr/venv/lib/python3.9/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/root/pyez_netaddr/venv/lib/python3.9/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/usr/local/lib/python3.9/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/usr/local/lib/python3.9/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/root/pyez_netaddr/py-junos-eznc/tests/functional/test_config.py", line 5, in <module>
    from skip_version import skip_for_version
ModuleNotFoundError: No module named 'skip_version'

----------------------------------------------------------------------
XML: /root/pyez_netaddr/py-junos-eznc/tests/functional/functionaltests.xml
/root/pyez_netaddr/py-junos-eznc/lib/jnpr/junos/transport/tty.py:56: DeprecationWarning: invalid escape sequence \s
  '(?P<cli>[^\\-"]>\s*$)',
Name                                                  Stmts   Miss  Cover
-------------------------------------------------------------------------
jnpr/junos/__init__.py                                   27      0   100%
jnpr/junos/_version.py                                  279    152    46%
jnpr/junos/console.py                                   173    135    22%
jnpr/junos/decorators.py                                114     33    71%
jnpr/junos/device.py                                    514    248    52%
jnpr/junos/exception.py                                 129     38    71%
jnpr/junos/factcache.py                                 102     58    43%
jnpr/junos/factory/__init__.py                            8      3    62%
jnpr/junos/factory/cfgtable.py                          281    240    15%
jnpr/junos/factory/cmdtable.py                          212    161    24%
jnpr/junos/factory/cmdview.py                            32      9    72%
jnpr/junos/factory/factory_cls.py                       106     72    32%
jnpr/junos/factory/factory_loader.py                    238    146    39%
jnpr/junos/factory/optable.py                            74     49    34%
jnpr/junos/factory/state_machine.py                     425    385     9%
jnpr/junos/factory/table.py                             156     61    61%
jnpr/junos/factory/to_json.py                            50     26    48%
jnpr/junos/factory/view.py                              166     91    45%
jnpr/junos/factory/viewfields.py                         34     14    59%
jnpr/junos/facts/__init__.py                             32      2    94%
jnpr/junos/facts/current_re.py                           53     33    38%
jnpr/junos/facts/domain.py                               25     19    24%
jnpr/junos/facts/ethernet_mac_table.py                   25     21    16%
jnpr/junos/facts/file_list.py                            13     10    23%
jnpr/junos/facts/get_chassis_cluster_status.py           26     22    15%
jnpr/junos/facts/get_chassis_inventory.py                15     10    33%
jnpr/junos/facts/get_route_engine_information.py         54     51     6%
jnpr/junos/facts/get_software_information.py            145     77    47%
jnpr/junos/facts/get_virtual_chassis_information.py      29     25    14%
jnpr/junos/facts/ifd_style.py                             9      6    33%
jnpr/junos/facts/iri_mapping.py                          39      1    97%
jnpr/junos/facts/is_linux.py                             14      3    79%
jnpr/junos/facts/personality.py                          67     63     6%
jnpr/junos/facts/swver.py                                64     33    48%
jnpr/junos/jxml.py                                       76     12    84%
jnpr/junos/ofacts/__init__.py                            11      0   100%
jnpr/junos/ofacts/chassis.py                             20     17    15%
jnpr/junos/ofacts/domain.py                              24     19    21%
jnpr/junos/ofacts/ifd_style.py                            5      4    20%
jnpr/junos/ofacts/personality.py                         41     39     5%
jnpr/junos/ofacts/routing_engines.py                     57     54     5%
jnpr/junos/ofacts/session.py                              3      1    67%
jnpr/junos/ofacts/srx_cluster.py                         15     14     7%
jnpr/junos/ofacts/switch_style.py                        14     12    14%
jnpr/junos/ofacts/swver.py                               56     52     7%
jnpr/junos/op/__init__.py                                28      3    89%
jnpr/junos/rpcmeta.py                                    95     32    66%
jnpr/junos/transport/__init__.py                          0      0   100%
jnpr/junos/transport/tty.py                             125     97    22%
jnpr/junos/transport/tty_netconf.py                     135     99    27%
jnpr/junos/transport/tty_serial.py                       47     32    32%
jnpr/junos/transport/tty_ssh.py                         116     84    28%
jnpr/junos/transport/tty_telnet.py                       61     39    36%
jnpr/junos/utils/__init__.py                              1      0   100%
jnpr/junos/utils/config.py                              293    133    55%
jnpr/junos/utils/fs.py                                  180    147    18%
jnpr/junos/utils/ftp.py                                  53     41    23%
jnpr/junos/utils/scp.py                                  37      2    95%
jnpr/junos/utils/ssh_client.py                           23      2    91%
jnpr/junos/utils/start_shell.py                          91     21    77%
jnpr/junos/utils/util.py                                 17      4    76%
jnpr/junos/version.py                                     8      2    75%
-------------------------------------------------------------------------
TOTAL                                                  5362   3259    39%
/root/pyez_netaddr/py-junos-eznc/lib/jnpr/junos/transport/tty.py:56: DeprecationWarning: invalid escape sequence \s
  '(?P<cli>[^\\-"]>\s*$)',
----------------------------------------------------------------------
Ran 42 tests in 69.701s

FAILED (errors=1)

Thanks.

@chidanandpujar chidanandpujar merged commit 4edfc73 into Juniper:master Sep 12, 2023
4 checks passed
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.

2 participants